admin管理员组文章数量:1022727
What if at some moment of time I need to get user input by calling dialog window or something like that. What is the best way to implement this using QML? Any analogs of prompt
in js?
What if at some moment of time I need to get user input by calling dialog window or something like that. What is the best way to implement this using QML? Any analogs of prompt
in js?
- 1 Are you targeting desktops, phones, or iPad type devices? – Nathaniel Johnson Commented May 26, 2014 at 16:51
- 1 This is a pretty broad question but I think one of the approaches using a Loader will work. qt-project/wiki/QML-Application-Structuring-Approaches – Nathaniel Johnson Commented May 26, 2014 at 16:54
1 Answer
Reset to default 3You can use Dialog
, available since Qt 5.3, and customize it as you wish.
Ensure, that you have this version installed and working.
Here you can find example.
Also, take a look at small example I've prepared:
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Dialogs 1.2
ApplicationWindow {
visible: true
width: 320
height: 240
title: qsTr("Custom Dialog")
Dialog {
id: customDialog
title: "Custom Dialog in QML/Qt 5.3"
standardButtons: StandardButton.Ok | StandardButton.Cancel
Column {
anchors.fill: parent
Text {
text: "Here goes all your custom elements..."
}
TextInput {
id: edtInput
text: "Input text"
}
}
onButtonClicked: {
if (clickedButton==StandardButton.Ok) {
console.log("Accepted " + clickedButton)
lblResults.text += edtInput.text
} else {
console.log("Rejected" + clickedButton)
}
}
}
Column {
anchors.fill: parent
Button {
text: qsTr("Call Custom dialog")
onClicked: customDialog.open()
}
Text {
id: lblResults
text: qsTr("Results: ")
}
}
}
What if at some moment of time I need to get user input by calling dialog window or something like that. What is the best way to implement this using QML? Any analogs of prompt
in js?
What if at some moment of time I need to get user input by calling dialog window or something like that. What is the best way to implement this using QML? Any analogs of prompt
in js?
- 1 Are you targeting desktops, phones, or iPad type devices? – Nathaniel Johnson Commented May 26, 2014 at 16:51
- 1 This is a pretty broad question but I think one of the approaches using a Loader will work. qt-project/wiki/QML-Application-Structuring-Approaches – Nathaniel Johnson Commented May 26, 2014 at 16:54
1 Answer
Reset to default 3You can use Dialog
, available since Qt 5.3, and customize it as you wish.
Ensure, that you have this version installed and working.
Here you can find example.
Also, take a look at small example I've prepared:
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Dialogs 1.2
ApplicationWindow {
visible: true
width: 320
height: 240
title: qsTr("Custom Dialog")
Dialog {
id: customDialog
title: "Custom Dialog in QML/Qt 5.3"
standardButtons: StandardButton.Ok | StandardButton.Cancel
Column {
anchors.fill: parent
Text {
text: "Here goes all your custom elements..."
}
TextInput {
id: edtInput
text: "Input text"
}
}
onButtonClicked: {
if (clickedButton==StandardButton.Ok) {
console.log("Accepted " + clickedButton)
lblResults.text += edtInput.text
} else {
console.log("Rejected" + clickedButton)
}
}
}
Column {
anchors.fill: parent
Button {
text: qsTr("Call Custom dialog")
onClicked: customDialog.open()
}
Text {
id: lblResults
text: qsTr("Results: ")
}
}
}
本文标签: javascriptUsing dialogs in QMLStack Overflow
版权声明:本文标题:javascript - Using dialogs in QML - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745488396a2152849.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论