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 actually activate sub tab ?
Qt 6.11 is out! See what's new in the release blog

How to actually activate sub tab ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 498 Views 2 Watching
  • 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
    Anonymous_Banned275
    wrote on last edited by
    #1

    I have a main QTab (ui->tabWidget) containing sub-tabs.
    I can switch / activate another tab using known index

    ui->tabWidget->setCurrentIndex(1);

    How can I
    select the new tab and also select one of its sub-tabs.

    Can that be done using sub-tab name instead of index?
    The sub-tab index is dynamic - new sub-tabs are added using slot.

    M 1 Reply Last reply
    0
    • A Anonymous_Banned275

      I have a main QTab (ui->tabWidget) containing sub-tabs.
      I can switch / activate another tab using known index

      ui->tabWidget->setCurrentIndex(1);

      How can I
      select the new tab and also select one of its sub-tabs.

      Can that be done using sub-tab name instead of index?
      The sub-tab index is dynamic - new sub-tabs are added using slot.

      M Offline
      M Offline
      mpergand
      wrote on last edited by mpergand
      #2

      @AnneRanch
      QTabWidget::widget(int index)
      returns the widget at index.
      If it's a tab, you have to make a cast:

      QWidget* w=tabWidget->widget(1);  // widget at tab index 1
      QTabWidget* subTab=qobject_cast<QTabWidget*>(w);
      
      if(subTab)
        {
        subTab->setCurrentIndex(0);  // select first tab
        }
      
      1 Reply Last reply
      1

      • Login

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