Object reference between two files over thrid



  • Hi,

    I try to address the QML-objects between different files:

    main.qml :
    Column
    {
    InfoView
    {
    id : info
    }
    ButtonBar { ... }
    }

    InfoView.qml :
    Row
    {
    Item
    {
    id : view3d
    InfoQt3d { ... }
    }
    }

    InfoQt3d.qml :
    Viewport
    {
    Item
    {
    id : castle
    Item3D { ... }
    }
    }

    ButtonBar.qml :
    Row
    {
    ButtonItem { ...; receiver : info; ... }
    ButtonItem { ...; receiver : view3d; ... }
    }

    In an example I try from file ButtonBar.qml (receiver : view3d) to adress objects in InfoQt3d.qml file (view3d or castle). Also I receive a error. Object "info" (receiver : info) is addressed normally.

    How i can to address view3d or castle objects from ButtonBar.qml file? Probably an example where such situation is described?

    thanks for answers,
    Sergej



  • The ids visible in ButtonBar are only the ids defined in ButtonBar or parents of ButtonBar. InfoView is a sibling in this case, so ids defined in InfoView will not be visible in ButtonBar.

    You need to forward it with properties. If InfoView's id view3d is to be visible to ButtonBar, add a property to ButtonBar:

    @property Item view3d@

    This should also be exposed from InfoView so that main.qml will look like this:

    @main.qml :
    Column {
    InfoView { id : info }
    ButtonBar { view3d: info.view3d }
    }@


Log in to reply
 

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