QTabWidgets , ways to find a tab.



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


  • Lifetime Qt Champion

    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



  • 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().


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.