⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

how to determine active tab in TabBar?

  • 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:

    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.


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

    Container currentIndex

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

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

Log in to reply