PDA

View Full Version : Qt Quick Components - layout of Dialog



finngruwier
2nd September 2011, 09:10
I try to make a Dialog, but I have problems making in look properly. It simply should display two buttons placed in each half of the screen. I haven't been able to find any relevant examples. The only way I can make it work is by placing the two buttons inside a Row, but then the buttons are piled up in the left side of the screen (since this is the way a Row works). I have tried other solutions such as placing the buttons inside an Item, but then only one button is showed!

Can anyone show me a basic code example of a Dialog with two buttons?

Ceaser88
2nd September 2011, 11:36
Check the row example in this link: http://doc.qt.nokia.com/4.7-snapshot/qml-positioners.html#repeaters
the solution is in how you anchor the buttons to the parent row

or you can also try inserting 2 columns as children within the row and then each button would be a child of a column

or you can use a grid (which is the same as the previous solution only easier)

Good Luck

finngruwier
2nd September 2011, 15:04
Thanks for the input. I actually ended up with a different solution. Here's my code for the dialog:



Dialog {
id: exitDialog
anchors.centerIn: parent
title: [
Text {
anchors.top: parent.top
anchors.topMargin: 10
anchors.left: parent.left
anchors.leftMargin: 10
font.bold: true
color: "white"
text: "Keep list?"
}
]
content: [
Button {
anchors.left: parent.left
anchors.leftMargin: 50
anchors.verticalCenter: parent.verticalCenter
text: "Yes"
},
Button {
anchors.right: parent.right
anchors.rightMargin: 50
anchors.verticalCenter: parent.verticalCenter
text: "No"
}
]
}

Ceaser88
13th September 2011, 16:28
That's the beauty of QML..there's always a ton of solutions