Вопрос

I have a few IntValidators inside as many TextInputs and they all behave well, except one. The one misbehaving is the only one with its bottom property set to something greater than zero. The problem is easily riproducible with the code below (Qt 5.2.0):

import QtQuick 2.1

Rectangle
{
    id:         mainwindow
    objectName: "mainwindow"
    width:      1024
    height:     768

    TextInput
    {
        id: testtextinput
        objectName: "testtextinput"

        text: "170"
        font.pixelSize: 36

        x: 100
        y: 200
        width: 200
        height: 200

        property size range: Qt.size(160, 180)
        validator: IntValidator
        {
            id:     rangevalidator
            objectName: testtextinput.objectName + "_rangevalidator"

            bottom: testtextinput.range.width
            top:    testtextinput.range.height

            Component.onCompleted:
            {
                console.log("Component.onCompleted objectName: " + objectName + " bottom: " + bottom + " top: " + top)
            }
        }
        onAccepted:
        {
            text = "accepted"
        }
    }
    Text
    {
        id: testisacceptable

        font.pixelSize: 36
        text: testtextinput.acceptableInput

        anchors.top: testtextinput.bottom
        anchors.left: testtextinput.left
        anchors.right: testtextinput.right
        height: 200
    }
}

The validator's range is set to [160, 180], so, if I want to type 181, I can just type 18 and nothing more. However, if I want to type 159, the TextInput allows me to write the whole number, tells me that the number won't be accepted setting to false the acceptableInput property, but when I press enter, the onAccepted() slot is executed without problems. Any ideas on what's happening here? A bug?

Это было полезно?

Решение

This bug is solved in Qt 5.3.0 as explained here.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top