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. How to get the page in QTabWidget

How to get the page in QTabWidget

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 238 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.
  • A Offline
    A Offline
    Ayush Gupta
    wrote on last edited by
    #1

    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
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      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
      4

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved