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 determine active tab in TabBar?

how to determine active tab in TabBar?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 708 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 -

    A view in my app uses a TabBar with three TabButtons:

    TabBar {
      property var tabNames: ["TabOne", "TabTwo", "TabThree"]
    
      Repeater {
        model: tabNames
        
        TabButton {
          id: tabButton
          text: tabNames[index]
    

    Which produces this lovely display:
    tabbar.PNG

    The legend at the lower right should only display when the first tab ("Yield") is selected. The original programmer attempted to do this with a property:

    Q_PROPERTY(bool viewingTheYield READ ViewingTheYield NOTIFY EventViewingTheYieldChanged)
    bool PlateNavigation::ViewingTheYield() const {
      return m_viewingTheYield;
    }
    

    If the user clicks on one of the other tabs, the legend disappears (as it should). But, if the user then loads a new report, this display returns to the last tab the previous report had selected (which it shouldn't). Somehow I need to control which tab is active...how do I do that? I can't find anything in the docs about it.

    Thanks...

    1 Reply Last reply
    0
    • mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #2

      Sigh...I love when I find the answer immediately after posting...

      Container currentIndex

      TabBar {
        id: root
        currentIndex: {
            if (plateNavViewModel.viewingTheYield) {
                0
            } else {
                2
            }
        }
      

      I know the hard-coding is bad, but...it works.

      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