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. Unexpected property value in Repeater in Qt 5.15.2
Forum Updated to NodeBB v4.3 + New Features

Unexpected property value in Repeater in Qt 5.15.2

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 171 Views
  • 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.
  • R Offline
    R Offline
    RoyG
    wrote on last edited by
    #1

    The final value of fooProperty seems to depend on whether fooProperty is referenced in onVisibleChanged. Does anyone understand what's leading to this behaviour?

    This changed when we upgraded from Qt 5.13 to 5.15.2.

    Main.qml

    import Qt.labs.platform 1.1
    import QtQuick 2.12
    import QtQuick.Window 2.3
    import QtQuick.Controls 2.5
    import QtGraphicalEffects 1.0
    import QtQuick.Layouts 1.3
    
    QQuickWindow {
        id: qQuickWindowInstance
    
        Repeater {
            model: 5
    
            Item {
                id: fooItem
    
                FooElement {
                    id: fooElementInstance
                    fooProperty: index
                    fooVisible: true
                }
    
                Component.onCompleted: {
                    // This is supposed to log 0 1 2 3 4, not -1 -1 -1 -1 -1
                    // fooProperty doesn't update with value of index if there is an onVisibleChanged function in fooElementInstance that refers to fooProperty
                    console.log("Main log fooProperty: ", fooElementInstance.fooProperty)
                }
            }
        }
    }
    

    FooElement.qml:

    import QtQuick 2.12
    import QtGraphicalEffects 1.13
    import QtQuick.Controls 2.5
    
    Item {
        id: fooElement
        property int fooProperty: -1
        property alias fooVisible: fooRectangle.visible
    
        Rectangle {
            id: fooRectangle
            visible: false
    
            onVisibleChanged: {
                // Comment the below out to have fooProperty take the correct value
                console.log("FooElement log fooProperty: ", fooElement.fooProperty)
            }
        }
    }
    
    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