Nominate our 2022 Qt Champions!

How to access object of dynamic object

  • I got var tabItem = tabView.getTab(idx).item;
    However I cannot access any object inside of tabitem like tabItem.rect.width.
    I can however access tabItem.property1.

    What to do to access Item of this tabItem?

  • @dmoviolin
    You may need to use property aliases at the root of your Tab's main Item to access those sub-items:

            TabView {
                id: tabView
                Tab {
                    title: "Red"
                    Rectangle {
                        id: test
                        color: "red"
                        property alias testText: testText
                        Text {
                            id: testText
                            text: "This is a test"
                    //Other tabs

    Then in JS:

    var tabItem = tabView.getTab(0).item

    Note how you can give the alias the same name as the id of the sub-item...

  • @dmoviolin
    Ever so grateful, it seems...

Log in to reply