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. How to access object of dynamic object

How to access object of dynamic object

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 472 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.
  • D Offline
    D Offline
    dmoviolin
    wrote on last edited by
    #1

    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?

    DiracsbracketD 2 Replies Last reply
    0
    • D dmoviolin

      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?

      DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by Diracsbracket
      #2

      @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
      console.debug(tabItem.testText.text)
      

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

      1 Reply Last reply
      2
      • D dmoviolin

        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?

        DiracsbracketD Offline
        DiracsbracketD Offline
        Diracsbracket
        wrote on last edited by Diracsbracket
        #3

        @dmoviolin
        Ever so grateful, it seems...

        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