Qt World Summit: Register Today!

Adding a tab in Widget from a class

  • I have one tabwidget in which i am adding tab like this
    @ tabWidget = new QTabWidget;
    tabWidget->addTab(new First_Tab(), tr("Home"));
    tabWidget->addTab(new Second_Tab(), tr("Guest"));@

    In the First_Tab, i am doing some search and after searching i want to show the result in another tab. Can anyone please guide me that how i can add another tab from the first_tab class? means when some conditions are filled and if i press the button show, a new tab opens and it shows all the search results. I already made the search tab just wanted to integrate it into this.

    tabWidget->addTab(new, Search_tab(),tr("Results"));

  • you should perhaps make it visible by using setVisible(true) to your tab.

  • by the way this is not some QML subject....

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    After adding the tab you should use either setCurrentIndex of setCurrentWidget to switch to your new tab.

    As dmcr noted, please chose the sub forum more carefully

Log in to reply