Wednesday, November 6, 2013

QtQuick.Controls example, RadioButton and GroupBox

qml example to implement QtQuick.Controls RadioButton and GroupBox.

QtQuick.Controls RadioButton and GroupBox
qml example of QtQuick.Controls RadioButton and GroupBox

import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0

ApplicationWindow {
    title: qsTr("qteveloper.blogspot.com")
    width: 400
    height: 350

    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            MenuItem {
                text: qsTr("Exit")
                onTriggered: Qt.quit();
            }
        }
    }

    ExclusiveGroup {
        id: exclusiveGroup1
    }

    ExclusiveGroup {
        id: exclusiveGroup2
    }

    Column{
        GroupBox {
            title: "GroupBox 1 (exclusive)"
            Column {
                RadioButton {
                    id: radioButton1a
                    text: "RadioButton 1a"
                    exclusiveGroup: exclusiveGroup1
                    checked: true
                }
                RadioButton {
                    id: radioButton1b
                    text: "RadioButton 1b"
                    exclusiveGroup: exclusiveGroup1
                }
                RadioButton {
                    id: radioButton1c
                    text: "RadioButton 1c"
                    exclusiveGroup: exclusiveGroup1
                }
            }
        }

        GroupBox {
            title: "GroupBox 2"
            Row {
                RadioButton {
                    id: radioButton2a
                    text: "2a"
                    checked: true
                }
                RadioButton {
                    id: radioButton2b
                    text: "2b"
                }
                RadioButton {
                    id: radioButton2c
                    text: "2c"
                }
            }
        }
    }
}