Hi Qt Masters,
Please advise any recommendations.
1) I'm having problem implementing the gridlayout columnspan. I wanted that when the orientation is portrait, the second row would span 2 columns and settings button will be centered.
property bool isPortrait : Screen.primaryOrientation === Qt.PortraitOrientation
GridLayout {
id: displayGrid
columnSpacing: 80
columns: isPortrait ? 2 : 3
rowSpacing: 80
rows: isPortrait ? 2 : 1
anchors.horizontalCenter: parent.horizontalCenter
Button{ id: fit }
Button { id: resize }
Button { id: settings }
}
property bool isPortrait : Screen.primaryOrientation === Qt.PortraitOrientation
GridLayout {
id: displayGrid
columnSpacing: 80
columns: isPortrait ? 2 : 3
rowSpacing: 80
rows: isPortrait ? 2 : 1
anchors.horizontalCenter: parent.horizontalCenter
Button{ id: fit }
Button { id: resize }
Button { id: settings }
}
To copy to clipboard, switch view to plain text mode
2) Another one is, I wanted to re-arrange the order of the model when the orientation is landscape. I tried creating 2 models and put a condition which model to use, however I encountered a problem wherein the last item overlaps the first item after I changed the orientation.
GridLayout {
id: totGrid
columnSpacing: isPortrait ? 50 : 30
columns: isPortrait ? 2 : 3
rowSpacing: isPortrait ? 50 : 30
rows: isPortrait ? 3 : 2
anchors {
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
}
Repeater {
id: totRepeater
model: listModel
Button {
text: title
}
}
}
ListModel {
id: listModel
ListElement {
title: "Input"
}
ListElement {
title: "Display"
}
ListElement {
title: "Record"
}
ListElement {
title: "Connect"
}
ListElement {
title: "Print"
}
ListElement {
title: "Save"
}
}
GridLayout {
id: totGrid
columnSpacing: isPortrait ? 50 : 30
columns: isPortrait ? 2 : 3
rowSpacing: isPortrait ? 50 : 30
rows: isPortrait ? 3 : 2
anchors {
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
}
Repeater {
id: totRepeater
model: listModel
Button {
text: title
}
}
}
ListModel {
id: listModel
ListElement {
title: "Input"
}
ListElement {
title: "Display"
}
ListElement {
title: "Record"
}
ListElement {
title: "Connect"
}
ListElement {
title: "Print"
}
ListElement {
title: "Save"
}
}
To copy to clipboard, switch view to plain text mode
Any help is greatly appreiated. TIA.
Bookmarks