Important: Please read the 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.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 something else...

Log in to reply