Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. New property value not overriding the old one.
Qt 6.11 is out! See what's new in the release blog

New property value not overriding the old one.

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    j_berry
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved