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. What is the best method to create a multi level GUI windows?
QtWS25 Last Chance

What is the best method to create a multi level GUI windows?

Scheduled Pinned Locked Moved Unsolved General and Desktop
gui designguiwidgets
4 Posts 4 Posters 742 Views
  • 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.
  • A Offline
    A Offline
    activeLearner
    wrote on 18 May 2021, 19:10 last edited by
    #1

    I want to create three levels of GUI windows. For example,
    Level 1 : Main Window with Button lables - "Living Beings" and "Non living Beings".
    Level 2: On clicking "Living Beings" I get another window where I have buttons with list of living beings such as "Human", "Elephant", "Tiger".
    Level 3: On clicking "Human" button I must get another window which has basic information about "Human".

    Now, I can implement this multi level GUI windows in two ways:

    1. All the window objects are created in the "main()" function and accordingly the objects are "show()ed".
    2. Objects of Level two are created in the constructors of Level one object windows. Objects of Level three are created in the constructors of Level two windows. This way I can free the objects of current level through the destructors of previous levels.

    Which one would be suggested during the implementation and why?

    T 1 Reply Last reply 21 May 2021, 17:08
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 18 May 2021, 19:16 last edited by
      #2

      Hi,

      It really depends on the purpose of your widgets and application. In such a simple case, you can do everything within your QMainWindow derived object.

      How you split things in your application will highly depend on what it does, what each of your widget is responsible for, how you want them to be testable, etc.

      There's no one solution fits all situations.

      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
      • J Online
        J Online
        JoeCFD
        wrote on 18 May 2021, 19:22 last edited by
        #3

        Use stackedwidget

        1 Reply Last reply
        0
        • A activeLearner
          18 May 2021, 19:10

          I want to create three levels of GUI windows. For example,
          Level 1 : Main Window with Button lables - "Living Beings" and "Non living Beings".
          Level 2: On clicking "Living Beings" I get another window where I have buttons with list of living beings such as "Human", "Elephant", "Tiger".
          Level 3: On clicking "Human" button I must get another window which has basic information about "Human".

          Now, I can implement this multi level GUI windows in two ways:

          1. All the window objects are created in the "main()" function and accordingly the objects are "show()ed".
          2. Objects of Level two are created in the constructors of Level one object windows. Objects of Level three are created in the constructors of Level two windows. This way I can free the objects of current level through the destructors of previous levels.

          Which one would be suggested during the implementation and why?

          T Offline
          T Offline
          Thank You
          wrote on 21 May 2021, 17:08 last edited by Thank You
          #4

          @activeLearner
          There are many ways to do it

            1. StackedWidgets
              It is simplest way to do the things that you have said. It may take memory but it is easiest method to solve this.
              How it works
              First Create buttons
              Add stacked widgets then you can create specific widgets such as human elephant in living beings. (You can promote widgets in ui too)
              Again you can add another stacked widgets inside that widget so it's most easy way to do so
              https://doc.qt.io/qt-5/qstackedwidget.html
            1. Simple dialogs || windows
              You can create windows on clicking the buttons and again inside it you can do same and achieve it. I don't recommend it as it looks so untidy
          • 3.tabWidget
            It's similar to stacked widgets but it looks more like your browser tabs
            You can create tabWidget inside it and do same for more deep
            https://doc.qt.io/qt-5/qtwidgets-dialogs-tabdialog-example.html
          • 4.Simple Widgets
            Another approach to get this is you can simply create widgets and
            use setVisible property to show on the basis of user clicks

          There is nothing that is best option. I like stackedWidget the most and can handle almost all things for simple development

          Let's make QT free or It will go forever

          TRUE AND FALSE <3

          1 Reply Last reply
          0

          1/4

          18 May 2021, 19:10

          • Login

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