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. Multiple Windows - best practise
Forum Updated to NodeBB v4.3 + New Features

Multiple Windows - best practise

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 519 Views 3 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.
  • L Offline
    L Offline
    leo738
    wrote on last edited by
    #1

    Hello all,
    I've used Qt before but not applications using multiple windows & would appreciate some pointers.

    I'm developing an embedded Linux project that'll have a number of windows or views, each requiring a different background image:

    1. Startup
    2. Running (requires some animation & counter)
    3. Finished
    4. Maintenance (requires pin input)

    My question is how should I best organise these different windows? Do I create different forms for each? If so should the main logic/ code be located in main.cpp that is then responsible for calling each form in turn?

    Apologies for such a simple question but I appreciate you looking!

    Leo

    jsulmJ S 2 Replies Last reply
    0
    • L leo738

      Hello all,
      I've used Qt before but not applications using multiple windows & would appreciate some pointers.

      I'm developing an embedded Linux project that'll have a number of windows or views, each requiring a different background image:

      1. Startup
      2. Running (requires some animation & counter)
      3. Finished
      4. Maintenance (requires pin input)

      My question is how should I best organise these different windows? Do I create different forms for each? If so should the main logic/ code be located in main.cpp that is then responsible for calling each form in turn?

      Apologies for such a simple question but I appreciate you looking!

      Leo

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @leo738 Take a look at https://doc.qt.io/qt-5/qstackedwidget.html
      You can use it to easily switch between different widgets.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • L Offline
        L Offline
        leo738
        wrote on last edited by
        #3

        Many thanks, will do!

        1 Reply Last reply
        0
        • L leo738

          Hello all,
          I've used Qt before but not applications using multiple windows & would appreciate some pointers.

          I'm developing an embedded Linux project that'll have a number of windows or views, each requiring a different background image:

          1. Startup
          2. Running (requires some animation & counter)
          3. Finished
          4. Maintenance (requires pin input)

          My question is how should I best organise these different windows? Do I create different forms for each? If so should the main logic/ code be located in main.cpp that is then responsible for calling each form in turn?

          Apologies for such a simple question but I appreciate you looking!

          Leo

          S Offline
          S Offline
          SimonSchroeder
          wrote on last edited by
          #4

          @leo738 said in Multiple Windows - best practise:

          If so should the main logic/ code be located in main.cpp that is then responsible for calling each form in turn?

          Your int main() function should have the event loop running. This at least forbids to run everything in turn from this function. You will need something derived from QObject (most of the time a QMainWindow) which has slots reacting to signals. Since it is its own object I suggest that it has its own .h and .cpp. So, no – normally you should not have this code in main.cpp.

          1 Reply Last reply
          0
          • E Offline
            E Offline
            Ewan Green
            wrote on last edited by
            #5

            This depends on how you want your "windows" to be laid out -- if you want to do like jsulm suggests, then it wouldn't be a matter of windows at all, just switching between widgets via. a stacked widget.

            If you want your windows to be represented as actual windows, you will need some sort of window hierarchy; I don't recommend using multiple QMainWindows, but rather using non-modal QDialogs spawned with a QMainWindow as a parent. They can directly interact via. signals and slots, and they will all close when the main window is closed. Hope this helps.

            Ewan Green

            1 Reply Last reply
            0
            • L Offline
              L Offline
              leo738
              wrote on last edited by
              #6

              Thanks for the replies!

              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