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. Create tabs for QTabWidget, but do not display all tabs.

Create tabs for QTabWidget, but do not display all tabs.

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 230 Views 1 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.
  • S Offline
    S Offline
    SRaD
    wrote on last edited by
    #1

    I've added tabs to my QTabWidget in the following way ...

    tabs = new QTabWidget;
    tabs->addTab(new Tab1(mywidget), tr("Tab 1"));
    tabs->addTab(new Tab2, tr("Tab 2"));
    

    Tab1 and Tab2 are classes derived from QWidget. I'd like to just create, say Tab2, but not actually display this tab. But somehow have a handle to the tabs I do not add yet so that I can add and remove them at will.

    How would this be done?

    Chris KawaC 1 Reply Last reply
    0
    • S SRaD

      I've added tabs to my QTabWidget in the following way ...

      tabs = new QTabWidget;
      tabs->addTab(new Tab1(mywidget), tr("Tab 1"));
      tabs->addTab(new Tab2, tr("Tab 2"));
      

      Tab1 and Tab2 are classes derived from QWidget. I'd like to just create, say Tab2, but not actually display this tab. But somehow have a handle to the tabs I do not add yet so that I can add and remove them at will.

      How would this be done?

      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I'd like to just create, say Tab2, but not actually display this tab.

      Simply QWidget* tab2 = new Tab2().

      But somehow have a handle to the tabs I do not add yet

      The pointer is a"handle".

      so that I can add and remove them at will.

      Just use addTab/removeTab as in your example whenever you need.

      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