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. [SOLVED] Go to a specific tab in a dialog

[SOLVED] Go to a specific tab in a dialog

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.4k 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.
  • G Offline
    G Offline
    gergnnud
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • IamSumitI Offline
      IamSumitI Offline
      IamSumit
      wrote on last edited by
      #2

      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

      Be Cute

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gergnnud
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • IamSumitI Offline
          IamSumitI Offline
          IamSumit
          wrote on last edited by
          #4

          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

          Be Cute

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gergnnud
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • IamSumitI Offline
              IamSumitI Offline
              IamSumit
              wrote on last edited by
              #6

              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.

              Be Cute

              1 Reply Last reply
              0
              • G Offline
                G Offline
                gergnnud
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0

                • Login

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