Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTabWidgets , ways to find a tab.
QtWS25 Last Chance

QTabWidgets , ways to find a tab.

Scheduled Pinned Locked Moved Solved General and Desktop
tabs
3 Posts 2 Posters 4.7k 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.
  • GofferG Offline
    GofferG Offline
    Goffer
    wrote on last edited by A Former User
    #1

    Hi community !

    I m currently dealing with Tabs
    And I can't find a way to get the index of a tab by passing the name of this tab.

    I have 2 solutions :

    1 - either I can get the index of the created tab at the creation step and then store it but no idea how to do that. or at least auto select the last created tab ? so from that i can get the index via currentIndex().

    EDIT :
    I can set the created tab by using QTabWidget.setCurentWidget(QWidget)

    2 - get the index based on the tab name ? Is that possible ?

    Thx !

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can use a loop and check the name of tab X where X is the for loop variable using the QTabBar of your QTabWidget.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • GofferG Offline
        GofferG Offline
        Goffer
        wrote on last edited by
        #3

        Hmm I thought about that but I wanted to avoid 'useless' iterations. What I have done is when i create my tab, I call the setCurrentWidget() and then I can get the Index with currentIndex().

        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