Search code examples
qmlqt5qtquick2qtquickcontrols

QML SpinBox - How to enable entering numbers when minimumValue is large?


If you create a SpinBox with a minimumValue of 100, it is difficult to manually enter numbers because validation happens as you type so any temporary value in the edit field that is outside the range bounds is prohibited.

Take a SpinBox supporting the range of 100-500:

import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2

ApplicationWindow {
    width: 300;  height: 200

    SpinBox {
        anchors.centerIn: parent
        minimumValue: 100; maximumValue: 500
    }
}

If you click into the input box, the entire value is selected and typing any number key would replace the current value with a single digit, which is less than 100 and therefore prevented. This renders pretty much any minimumValue above 1 useless.

But I really like all the other behavior I get from the SpinBox. Any suggestions?


Solution

  • BaCaRoZzo answered this: it's a QML defect that has been addressed as of Qt 5.4.1 and can no longer be reproduced.