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] Strategy for displaying different forms in same main window

[SOLVED] Strategy for displaying different forms in same main window

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

    As the title says, what is the best strategy to show different forms in the one main window depending on state?

    Say that to get to form B, the user must first interact with form A. To that end, I would like to to show form A and, when appropriate, close form A and show form B, all while keeping the menu, tool and status bars in the same one main window (menu and tool bars would have to be updated and items enabled/disabled accordingly).

    So far I have only been playing with wizard-generated code and it isn't immediately clear to me if this is possible to achieve (correction: it's Qt so it should be possible!). Would appreciate some help.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Sure it's possible. However you'll have to write the logic a bit. For the widget switching itself a QStackedWidget can contain them. Set that QStackedWidget as central widget of your QMainWindow and you have your starting point.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        miguelg
        wrote on last edited by
        #3

        Thanks for your reply.

        QStackedWidget does seem to be what I'm looking for! -I have a question though.-

        -I'm not sure if I'm doing it right but I have tried to promote the QWidget class of the wizard-generated MainWindow to QStackedWidget but it won't let me -- "screenshot here":http://www.zimagez.com/zimage/screenshot-230115-170043.php.-

        EDIT

        Please ignore. I was overcomplicating this when it is a simple matter of adding the "Stacked Widget" in to the Main Window form and then working on the stacked widget's logic.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Don't worry, it happens to all of us :)

          Happy coding !

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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