New property value not overriding the old one.



  • I'm trying to use a style sheet to provide default values to use throughout my application.
    The method I am using is described here: http://developer.qt.nokia.com/wiki/QmlStyling Approach 1 (I actually want to use Approach 3, but the problem is simplified with 1). Everything works fine until I want to override one of the styled values in a particular instance.

    I will explain my problem by showing code that does work, then making a very minor alteration, which causes it to stop working for no reason that I can understand.

    The code that works
    @
    //StyledText.qml
    import Qt 4.7
    Text
    {
    color: 'red'
    font.family: "Arial"
    font.pixelSize: 16
    font.bold: true
    }
    @
    @
    //test.qml
    import Qt 4.7
    StyledText
    {
    text:"text"
    font.pixelSize:30
    }
    @

    Fine, the text displays will all my styled properties except that it is size 30

    Now, if I modify StyledText.qml, so that the property font.pixelsize is a JS calculation rather than a simple integer:

    StyledText.qml
    @
    ...
    font.pixelsize: 10+6
    ...
    @
    or
    @
    ...
    font.pixelSize: otherObject.property
    ...
    @
    or
    @
    ...
    font.pixelSize: (16)
    ...
    @

    my text then displays at the size 16, not 30. The second one of those becomes important if I want to use Approach 3.

    Interestingly the problem is fixed if test.qml is modified in the same way:

    @
    //test.qml
    ...
    font.pixelSize: (30)
    ...
    @

    is this a bug?



  • Hi,

    This was indeed a bug, but it should be working correctly in HEAD of 4.7. It was either fixed in 4.7.2 (see http://bugreports.qt.nokia.com/browse/QTBUG-13719) or will be fixed in the upcoming 4.7.3. If you are not yet using 4.7.2, I'd suggest updating and giving it a try there.

    Regards,
    Michael


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.