Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved How to get the page in QTabWidget

    General and Desktop
    2
    2
    100
    Loading More Posts
    • 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.
    • A
      Ayush Gupta last edited by

      I have below code
      QTabWidget* TabWidget = new QTabWidget(this);

      I am adding tabs with below code I have some QWidget user define class name like WigetTreeView;

      WidgetTreeView *tab1 = new WidgetTreeView(this);
      now I am adding this tab using below code.

      TabWidget ->addTab(tab1 , "Tab1");

      Now I need to get the the index of tab using tab name "Tab1" from TabWidget .

      How Can I do that?

      I tried findchildren<> method but it did not work for me.
      indexof() of QTabWidget always return -1;

      1 Reply Last reply Reply Quote 0
      • V
        VRonin last edited by

        Just iterate.

        for(int i=0;i<tabWidget->count();++i){
        if(tabWidget->tabText(i) == QStringLiteral("Tab1"))
        qDebug("Bingo!");
        }
        

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply Reply Quote 4
        • V
          VRonin last edited by

          Just iterate.

          for(int i=0;i<tabWidget->count();++i){
          if(tabWidget->tabText(i) == QStringLiteral("Tab1"))
          qDebug("Bingo!");
          }
          

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply Reply Quote 4
          • First post
            Last post