QML: Access parent attributes in setProperty



  • I have a QML application that can be updated through a Lua environment. I wish to be able to set relative attributes of a element, such as:

    updateQML("gaugeFront", "width", "parent.width")

    I can update it with:
    updateQML("gaugeFront", "width", 50)

    The relevant piece of C++ is:
    child->setProperty( property, value);//child being gaugeFront, property being width, value being 50

    or anything else, but updating it by trying to access the parent elements doesn't work. The .qml file has a parent.width/parent.height which works for the gaugeFront element.

    I can fall back to a getQML("parent name", "width") to do this, but would rather keep things relative and make use of the natural hierarchy. Is there something I'm missing to be able to set attributes relative to already defined objects?


Log in to reply
 

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