Hm….
I’m using Window component to create dialogs. So, when I need to create custom dialog I use something like this:
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Window 2.0
Window {
id: controllerWindow
width: 600
height: 300
minimumWidth: 600
maximumWidth: 600
minimumHeight: 300
maximumHeight: 300
modality: Qt.WindowModal
title: qsTr("Window title")
color: "#e8e8e8"
//Any properties, functions etc.
Rectangle {
id: generalTabContent
anchors {fill: parent; margins:10}
color: "transparent"
Rectangle {
id: generalContentView
width: parent.width
height: parent.height - 10 - buttonsRow.height
color: "red"
}
Row {
id: buttonsRow
anchors {top: generalContentView.bottom; right: parent.right; topMargin: 10}
width: btnClose.width + btnSave.width
height: btnClose.height
Button {
id: btnClose
text: qsTr("Close")
onClicked: {
controllerWindow.close();
}
}
Button {
id: btnSave
text: qsTr("Save")
onClicked: {
//Some code here
controllerWindow.close();
}
}
}
}
}
Certainly, you can create qml file with code upper and implement all logic in this qml file. If you need to return some datas in this case you can use signal/slot. [qt-project.org] Also you can set any properties (custom properties you must implement in you Window qml file) in opitions variable.
If you have any question let me know and I’ll try to help you.
↧