Skip to content

Instantly share code, notes, and snippets.

@agentsim
Created December 15, 2015 02:28
Show Gist options
  • Save agentsim/bb466c86acc7b89a27d4 to your computer and use it in GitHub Desktop.
Save agentsim/bb466c86acc7b89a27d4 to your computer and use it in GitHub Desktop.
Illustration of QML Warnings
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2
import QtQuick.Window 2.2
Window {
id: window
width: 600
height: 400
minimumWidth: 500
minimumHeight: 300
Rectangle {
id: sideBar
anchors {
top: parent.top
left: parent.left
}
width: 75
height: parent.height
color: "lightgrey"
Column {
ExclusiveGroup { id: group }
anchors {
fill: parent
topMargin: 50
}
RadioButton {
exclusiveGroup: group
text: "Tab1"
checked: true
onCheckedChanged: {
if (checked === true) {
page.source = "Tab1.qml"
}
}
}
RadioButton {
exclusiveGroup: group
text: "Tab2"
checked: false
onCheckedChanged: {
if (checked === true) {
page.source = "Tab2.qml"
}
}
}
}
}
Loader {
id: page
source: "Tab1.qml"
anchors {
top: parent.top
left: sideBar.right
right: parent.right
bottom: parent.bottom
}
}
}
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.2
Item {
GridLayout {
columns: 2
columnSpacing: 10
rowSpacing: 1
Label {
id: formatLbl
Layout.fillWidth: true
horizontalAlignment: Text.AlignRight
text: qsTr("A Field:")
}
ComboBox {
id: fmtCombo
model: model
Layout.fillWidth: true
Layout.column: 1
}
Item { height: 14; Layout.row: 2 }
Label {
id: rateLbl
Layout.fillWidth: true
Layout.row: 3
text: qsTr("Another field:")
horizontalAlignment: Text.AlignRight
}
ComboBox {
id: rateCombo
model: model
Layout.fillWidth: true
Layout.column: 1
Layout.row: 3
}
}
ListModel {
id: model
ListElement {
text: "Item 1"
}
ListElement {
text: "Item 2"
}
ListElement {
text: "Item 3"
}
}
}
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.2
Item {
GridLayout {
columns: 2
columnSpacing: 10
rowSpacing: 1
Label {
id: formatLbl
Layout.fillWidth: true
horizontalAlignment: Text.AlignRight
text: qsTr("Tab2 field:")
}
ComboBox {
id: fmtCombo
model: model
Layout.fillWidth: true
Layout.column: 1
}
Item { height: 14; Layout.row: 2 }
Label {
id: rateLbl
Layout.fillWidth: true
Layout.row: 3
text: qsTr("Another tab2 field:")
horizontalAlignment: Text.AlignRight
}
ComboBox {
id: rateCombo
model: model
Layout.fillWidth: true
Layout.column: 1
Layout.row: 3
}
}
ListModel {
id: model
ListElement {
text: "Item 1"
}
ListElement {
text: "Item 2"
}
ListElement {
text: "Item 3"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment