[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.htmland 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.
-
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.