Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Property substituted with 0 in QML



  • I'm facing an annoying problem. I'm editing a QML file, here an extract:

    Rectangle {
        id: root
        visible: true
        color: "black"
    
        readonly property int xText: 100
        readonly property int yText: 210
        readonly property int fontSize: 96
    
        FontLoader {
            id: myfont_bold
            source: "qrc:/font/MyFont Bold.ttf"
        }
    
        Text {
            x: xText
            y: yText
            color: "white"
            horizontalAlignment: Text.AlignRight
            font.family: myfont_bold.name
            font.pixelSize: fontSize
            text: "30"
        }
    }
    

    When I move away from line font.pixelSize: fontSize or even just compile, the editor changes this line to:

    font.pixelSize: 0
    

    This doesn't happens every time, but quite often. What's wrong here?
    I'm using Qt5.11.1 and QtCreator 4.8.1.

    UPDATE: I've just discovered it replace also literal values, like font.pixelSize: 96. In this case the "edited" line is quite weird:

    font.pixelSize: 966
    

    or

    font.pixelSize:96
    

    or something else...


Log in to reply