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. [Solved] Access to object properties in a tab element
QtWS25 Last Chance

[Solved] Access to object properties in a tab element

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 2.0k 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.
  • mrdebugM Offline
    mrdebugM Offline
    mrdebug
    wrote on last edited by mrdebug
    #1

    Hi. My situation is

        TabView {
            id: twUser
    
            Tab {
                id: tSurname
    
                    Text {
                        id: text2
                        text: 'Hello'
    

    Is there a way to access the text properties of text2 element?

    Need programmers to hire?
    www.labcsp.com
    www.denisgottardello.it
    GMT+1
    Skype: mrdebug

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      inside the QML module all ids are available so you can write text2.text to read the value.

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • mrdebugM Offline
        mrdebugM Offline
        mrdebug
        wrote on last edited by
        #3

        No, with TabView is different. text2 is unavailable.
        Outside TabView I can access only at the tab but not at the objects inside the tab.
        I can access to tSurname but I obtain an error when I try to access to text2.
        Is there a way?

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        p3c0P 1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          If you are outside TabView you can create a property alias pointing to the text2.text

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          0
          • mrdebugM mrdebug

            No, with TabView is different. text2 is unavailable.
            Outside TabView I can access only at the tab but not at the objects inside the tab.
            I can access to tSurname but I obtain an error when I try to access to text2.
            Is there a way?

            p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by p3c0
            #5

            @mrdebug Use getTab to get the Tab at a particular index. Now since Tab inherits Loader you can use its item property to access the item it contains. Eg:

            var tab = tabv.getTab(0) //get tab at index 0; tabv = id of TabView
            console.log(tab.item.text) //get the item and access its properties
            

            157

            1 Reply Last reply
            0
            • mrdebugM Offline
              mrdebugM Offline
              mrdebug
              wrote on last edited by
              #6

              Perfect!

              Need programmers to hire?
              www.labcsp.com
              www.denisgottardello.it
              GMT+1
              Skype: mrdebug

              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