[SOLVED] Go to a specific tab in a dialog



  • Is there any way to open a tabbed dialog from the main window and also go to a specific tab?

    @void MainWindow::on_actionProcess_triggered()
    {
    Settings settings;
    settings.setModal(true);
    settings.exec();
    //somehow also go to the 'Process' tab
    } @

    Where 'settings' is the modal popup dialog containing tabs such as Process, Options, General etc.



  • hi
    and welcome to devnet yes it ts
    see
    "QTabWidget":http://qt-project.org/doc/qt-5/QTabWidget.html

    and to switch on specific tab
    use ->void setCurrentIndex(int index)

    hope it helps



  • Thanks for the prompt response but, being a complete noob I don't quite get it.

    I understand that the settings dialog has a QTabWidget that contains tabs as named above (well to be more precise - tab_Process, tab_Options, etc.) but I wouldn't have clue how ->void setCurrentIndex(int index) could be interpreted and then used in the code above.

    I have menu items in the main window for each tab in the settings dialog popup. At the moment they all do the same thing and open in whichever tab was on top before compiling.

    Could you explain in a little more detail please?

    Thanks.



  • Hi.
    yeah you can do it
    the tab that you want to open you need to get index of that tab.

    then emit void QTabWidget::tabBarClicked(int index) [signal] by passing that index.
    then it will be selectable



  • For anyone interested this ended up being a very simple one to solve. Learning bit by bit.

    @void MainWindow::on_actionProcess_triggered()
    {
    Settings settings;
    settings.setModal(true);
    settings.tabWidget->setCurrentIndex(3);
    settings.exec();
    }@

    Tabs are indexed from left to right starting with 0 so, in this example, the 'Process' tab is the fourth tab along (index=3) and needs to be set before executing. Thanks to IamSumit for giving me some things to Google.



  • Hi.
    that's nice.
    if your problem is solved;please make thread title as SOLVED,so others can know that solution has been found.
    Thanks.



  • I can't see where I can mark as solved. Do I just edit the first post?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.