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. extracting value from child component
Qt 6.11 is out! See what's new in the release blog

extracting value from child component

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 240 Views 1 Watching
  • 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by mzimmers
    #1

    Hi all -

    Imagine that I have a main.qml:

        ColumnLayout {
            Navbar {
                id: navBar
            }
            Mainarea {
                currentIndex: navTabs.currentIndex // this doesn't work of course
            }
    

    And Navbar.qml:

    Item {
        id: bigPicture
        Rectangle {
            id: navBar
            TabBar {
                id: navTabs
    ...
    

    How can I find the currentIndex of the TabBar from my Mainarea object?

    Thanks...

    mzimmersM 1 Reply Last reply
    0
    • mzimmersM mzimmers

      Hi all -

      Imagine that I have a main.qml:

          ColumnLayout {
              Navbar {
                  id: navBar
              }
              Mainarea {
                  currentIndex: navTabs.currentIndex // this doesn't work of course
              }
      

      And Navbar.qml:

      Item {
          id: bigPicture
          Rectangle {
              id: navBar
              TabBar {
                  id: navTabs
      ...
      

      How can I find the currentIndex of the TabBar from my Mainarea object?

      Thanks...

      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #2

      Got it...property alias. Added a line to Navbar.qml:

      Item {
          id: bigPicture
          property alias tabIndex: navTabs.currentIndex // the new line
          Rectangle {
              id: navBar
              TabBar {
                  id: navTabs
      ...
      

      And in main.qml:

              Navbar {
                  id: navBar
              }
              Mainarea {
                  currentIndex: navBar.tabIndex
              }
      

      Seems to work, but if someone knows of a better way, I'm open to suggestions. Thanks for looking...

      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