Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Understand multi-page GUI and multi-platform GUI
Forum Updated to NodeBB v4.3 + New Features

Understand multi-page GUI and multi-platform GUI

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
12 Posts 5 Posters 2.6k 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.
  • GiridharG Offline
    GiridharG Offline
    Giridhar
    wrote on last edited by
    #1

    Hello everybody. I'm here to ask you something about GUIs. I have been using QT for about a year and I'm not a beginner at C++. First of all, I need to understand how to switch between different pages. I saw something about StackedWidget class but all the references that I found use a single .ui file with all the pages inside it and the .cpp file too.
    At the moment, I'm using multiple .ui files and multiple .cpp, .h files (one C++ class per .ui file) because each .ui file need its different logic and I use the methods "show" and "hide" to switch between pages but there is a problem because when I switch from a page to another I see the desktop. So, could I use the StackedWidget approach to use different .cpp and .ui files? How could I do it? Furthermore, I'm using a RaspBerry PI, is this approach performing? I don't want to load every page in memory before to show it.
    Secondly, if I would compile this application for mobile devices too, does the style of the buttons and of the other stuff changes automatically?

    Founder & Developer of: https://pidmx.net
    Mac - Qt6 for Rpi4 CrossCompile Environment tutorial: https://github.com/giridhar123/Qt-Rpi4-Mac-Cross-Compile

    mzimmersM 1 Reply Last reply
    0
    • GiridharG Giridhar

      Hello everybody. I'm here to ask you something about GUIs. I have been using QT for about a year and I'm not a beginner at C++. First of all, I need to understand how to switch between different pages. I saw something about StackedWidget class but all the references that I found use a single .ui file with all the pages inside it and the .cpp file too.
      At the moment, I'm using multiple .ui files and multiple .cpp, .h files (one C++ class per .ui file) because each .ui file need its different logic and I use the methods "show" and "hide" to switch between pages but there is a problem because when I switch from a page to another I see the desktop. So, could I use the StackedWidget approach to use different .cpp and .ui files? How could I do it? Furthermore, I'm using a RaspBerry PI, is this approach performing? I don't want to load every page in memory before to show it.
      Secondly, if I would compile this application for mobile devices too, does the style of the buttons and of the other stuff changes automatically?

      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #2

      @Giridhar first off, I'm wondering why you posted this in the QML forum, as it seems that your application uses Widgets, not QML.

      Many (most?) apps feature a main window, and in the course of user interaction will open other windows as appropriate. Are you trying to hide the main window when other windows appear?

      1 Reply Last reply
      0
      • GiridharG Offline
        GiridharG Offline
        Giridhar
        wrote on last edited by
        #3

        @mzimmers Because i din't find a correct section to post this.
        By the way, I do not found anything that explain the difference between widgets and QML. Everybody say: "for desktop use widget, for mobile use QML", but which are the differences on creating the app, or on code?

        What I could say is I use the .ui file editor to put buttons and other stuff in the interface an sometimes I use c++ to change visibility or to remove/add new object depending on app's state. Is there a reference that explain everything good? How can I switch from a window to another rapidly?

        Founder & Developer of: https://pidmx.net
        Mac - Qt6 for Rpi4 CrossCompile Environment tutorial: https://github.com/giridhar123/Qt-Rpi4-Mac-Cross-Compile

        mzimmersM 1 Reply Last reply
        0
        • GiridharG Giridhar

          @mzimmers Because i din't find a correct section to post this.
          By the way, I do not found anything that explain the difference between widgets and QML. Everybody say: "for desktop use widget, for mobile use QML", but which are the differences on creating the app, or on code?

          What I could say is I use the .ui file editor to put buttons and other stuff in the interface an sometimes I use c++ to change visibility or to remove/add new object depending on app's state. Is there a reference that explain everything good? How can I switch from a window to another rapidly?

          mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #4

          @Giridhar this forum's OK but you'd probably get more viewers (and answers) if you posted in General and Desktop.

          QML is a declarative way of creating UIs, while QWidgets are C++ classes. I too have heard that QML is preferred for mobile applications, but I'm not sure how big a difference it really makes. Personally, I'm more comfortable with QWidgets.

          This page is a good start on explaining windows and displays within the Qt system.

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

            Moved to "Mobile and Embedded" since it's the final targets.

            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
            • S Offline
              S Offline
              SimonSchroeder
              wrote on last edited by
              #6

              On mobile devices there is only QML and no support for QWidgets. That is one of the major reasons between the two. QWidgets tries to use native APIs as much as possible. Windows and macOS have mostly the same widgets which are unified through QWidgets. QML is also more of a descriptive language similar to HTML and CSS. It is supposed to be more intuitive for designers.

              Back to the original question. Using a QStackedWidget is the right approach. You can have separate ui-files for the separate pages of your stacked widget. I would then suggest that you create your QStackedWidget in C++. For each of the ui-files create a QWidget and the appropriate ui object. Then call ui->setupUi(widget) for each pair of ui and QWidget. Finally, add the widgets to the QStackedWidget as pages.

              jsulmJ GiridharG 2 Replies Last reply
              0
              • S SimonSchroeder

                On mobile devices there is only QML and no support for QWidgets. That is one of the major reasons between the two. QWidgets tries to use native APIs as much as possible. Windows and macOS have mostly the same widgets which are unified through QWidgets. QML is also more of a descriptive language similar to HTML and CSS. It is supposed to be more intuitive for designers.

                Back to the original question. Using a QStackedWidget is the right approach. You can have separate ui-files for the separate pages of your stacked widget. I would then suggest that you create your QStackedWidget in C++. For each of the ui-files create a QWidget and the appropriate ui object. Then call ui->setupUi(widget) for each pair of ui and QWidget. Finally, add the widgets to the QStackedWidget as pages.

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

                @SimonSchroeder said in Understand multi-page GUI and multi-platform GUI:

                On mobile devices there is only QML and no support for QWidgets

                This is new to me. I'm quite sure QWidgets are available on mobile devices.

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

                SGaistS 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @SimonSchroeder said in Understand multi-page GUI and multi-platform GUI:

                  On mobile devices there is only QML and no support for QWidgets

                  This is new to me. I'm quite sure QWidgets are available on mobile devices.

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @jsulm said in Understand multi-page GUI and multi-platform GUI:

                  @SimonSchroeder said in Understand multi-page GUI and multi-platform GUI:

                  On mobile devices there is only QML and no support for QWidgets

                  This is new to me. I'm quite sure QWidgets are available on mobile devices.

                  Yes they are, not optimised for that use case but yes they are.

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

                  S 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    @jsulm said in Understand multi-page GUI and multi-platform GUI:

                    @SimonSchroeder said in Understand multi-page GUI and multi-platform GUI:

                    On mobile devices there is only QML and no support for QWidgets

                    This is new to me. I'm quite sure QWidgets are available on mobile devices.

                    Yes they are, not optimised for that use case but yes they are.

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

                    @SGaist said in Understand multi-page GUI and multi-platform GUI:

                    Yes they are, not optimised for that use case but yes they are.

                    Thanks for the clarification.

                    1 Reply Last reply
                    0
                    • S SimonSchroeder

                      On mobile devices there is only QML and no support for QWidgets. That is one of the major reasons between the two. QWidgets tries to use native APIs as much as possible. Windows and macOS have mostly the same widgets which are unified through QWidgets. QML is also more of a descriptive language similar to HTML and CSS. It is supposed to be more intuitive for designers.

                      Back to the original question. Using a QStackedWidget is the right approach. You can have separate ui-files for the separate pages of your stacked widget. I would then suggest that you create your QStackedWidget in C++. For each of the ui-files create a QWidget and the appropriate ui object. Then call ui->setupUi(widget) for each pair of ui and QWidget. Finally, add the widgets to the QStackedWidget as pages.

                      GiridharG Offline
                      GiridharG Offline
                      Giridhar
                      wrote on last edited by
                      #10

                      @SimonSchroeder said in Understand multi-page GUI and multi-platform GUI:

                      On mobile devices there is only QML and no support for QWidgets. That is one of the major reasons between the two. QWidgets tries to use native APIs as much as possible. Windows and macOS have mostly the same widgets which are unified through QWidgets. QML is also more of a descriptive language similar to HTML and CSS. It is supposed to be more intuitive for designers.

                      Back to the original question. Using a QStackedWidget is the right approach. You can have separate ui-files for the separate pages of your stacked widget. I would then suggest that you create your QStackedWidget in C++. For each of the ui-files create a QWidget and the appropriate ui object. Then call ui->setupUi(widget) for each pair of ui and QWidget. Finally, add the widgets to the QStackedWidget as pages.

                      Ok, sI will develop a cross-platform application to be runnable on desktop, mobile and embedded, is it possible to implement this behaviour? I still didn't try it, I'm still understanding which is the best way to make an UI. For example, I did a web app using HTML/CSS/JS and using the Bootstrap framework. Why should I not use HTML + CSS + JS + WebKit and I should use QML?
                      I think that there are a lot of way to do the same thing and I get confused because I don't know how to choose the best one. I understood that QWidget are not the best approach for me 😁

                      Founder & Developer of: https://pidmx.net
                      Mac - Qt6 for Rpi4 CrossCompile Environment tutorial: https://github.com/giridhar123/Qt-Rpi4-Mac-Cross-Compile

                      1 Reply Last reply
                      0
                      • GiridharG Offline
                        GiridharG Offline
                        Giridhar
                        wrote on last edited by Giridhar
                        #11

                        I started to follow this playlist on youtube:
                        link

                        It's really nice and I'm learning a lot

                        Founder & Developer of: https://pidmx.net
                        Mac - Qt6 for Rpi4 CrossCompile Environment tutorial: https://github.com/giridhar123/Qt-Rpi4-Mac-Cross-Compile

                        mzimmersM 1 Reply Last reply
                        1
                        • GiridharG Giridhar

                          I started to follow this playlist on youtube:
                          link

                          It's really nice and I'm learning a lot

                          mzimmersM Offline
                          mzimmersM Offline
                          mzimmers
                          wrote on last edited by
                          #12

                          @Giridhar I've been watching ever since I saw your post. Agreed -- this is an excellent set of tutorials on QML.

                          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