Monday, November 18, 2013

Example of QtQuick.Controls SpinBox

Example to implement QtQuick.Controls SpinBox with qml.

QtQuick.Controls SpinBox
example of QtQuick.Controls SpinBox

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();
            }
        }
    }

    Column{
        Label {
            id: label
        }

        SpinBox{
            id: spinbox1
            width: 100
            maximumValue: 100
            minimumValue: 0
            value: 50
            onValueChanged: label.text = "spinbox1: " + value
        }
        SpinBox{
            id: spinbox2
            width: 100
            maximumValue: 100
            minimumValue: 0
            value: 50
            stepSize: 5
            prefix: "prefix: "
            onValueChanged: label.text = "spinbox2: " + value
        }
        SpinBox{
            id: spinbox3
            width: 100
            maximumValue: 100
            minimumValue: 0
            value: 50
            stepSize: 10
            suffix: "-suffix"
            onValueChanged: label.text = "spinbox3: " + value
        }

    }
}