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. QStackedWidget: Loading the widget/class object
Forum Updated to NodeBB v4.3 + New Features

QStackedWidget: Loading the widget/class object

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 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.
  • ahsan737A Offline
    ahsan737A Offline
    ahsan737
    wrote on last edited by
    #1

    I am working on a QStackedWidget based application. when the application runs then load all the classes with initial settings. How can I reload the class object when that particular widget is being displayed? because it has to adapt to the settings.

    JonBJ A 2 Replies Last reply
    0
    • ahsan737A ahsan737

      I am working on a QStackedWidget based application. when the application runs then load all the classes with initial settings. How can I reload the class object when that particular widget is being displayed? because it has to adapt to the settings.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @ahsan737
      It is not clear what you mean in this question.

      If you need the widget to completely reset when "loading" the page, you might discard the current widget and do a fresh new .... If that is what you are saying.

      ahsan737A 1 Reply Last reply
      0
      • JonBJ JonB

        @ahsan737
        It is not clear what you mean in this question.

        If you need the widget to completely reset when "loading" the page, you might discard the current widget and do a fresh new .... If that is what you are saying.

        ahsan737A Offline
        ahsan737A Offline
        ahsan737
        wrote on last edited by
        #3

        @JonB I want the widget to reload all the parameters when it comes in view (set as current widget in QStackedWidget). I am loading designer UI forms to stackwidget. Currently it is being loaded with the very initial parameters, and not adapting to the recent changes.

        JonBJ 1 Reply Last reply
        0
        • ahsan737A ahsan737

          @JonB I want the widget to reload all the parameters when it comes in view (set as current widget in QStackedWidget). I am loading designer UI forms to stackwidget. Currently it is being loaded with the very initial parameters, and not adapting to the recent changes.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @ahsan737
          If you mean the user makes changes in the widget and then when he goes back there the changes are lost, than actually sounds like you are reloading the widget from the UI template each time? You only want to load the template once to create an instance (at start-up time, or the first time the page is to be shown), put that into the stacked widget and then do not reload from the design-time template?

          ahsan737A 1 Reply Last reply
          1
          • JonBJ JonB

            @ahsan737
            If you mean the user makes changes in the widget and then when he goes back there the changes are lost, than actually sounds like you are reloading the widget from the UI template each time? You only want to load the template once to create an instance (at start-up time, or the first time the page is to be shown), put that into the stacked widget and then do not reload from the design-time template?

            ahsan737A Offline
            ahsan737A Offline
            ahsan737
            wrote on last edited by
            #5

            @JonB let me explain it clearly, I want that when widget No. 6 gets loaded then it should adapt to the changes made in the previous 5 widgets. But currently widget 6 is being loaded with default values, and isn't responding to the changes made (parameters defined) in previous screens.

            JonBJ 1 Reply Last reply
            0
            • ahsan737A ahsan737

              @JonB let me explain it clearly, I want that when widget No. 6 gets loaded then it should adapt to the changes made in the previous 5 widgets. But currently widget 6 is being loaded with default values, and isn't responding to the changes made (parameters defined) in previous screens.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @ahsan737
              Still don't understand! How does "a widget adapt to the changes made in the previous 5 widgets", what does that mean? You have to do whatever to pick stuff up from other widgets (pages?) if you want those copied into another widget (page)? Is that what you asking about??

              Maybe show some code?

              ahsan737A 2 Replies Last reply
              1
              • JonBJ JonB

                @ahsan737
                Still don't understand! How does "a widget adapt to the changes made in the previous 5 widgets", what does that mean? You have to do whatever to pick stuff up from other widgets (pages?) if you want those copied into another widget (page)? Is that what you asking about??

                Maybe show some code?

                ahsan737A Offline
                ahsan737A Offline
                ahsan737
                wrote on last edited by
                #7

                @JonB the application is in a flow. a user is being asked to input parameters one by one (first 5 or 6 screens), and then a graph is being plotted (at screen 7) which will take the previous data as input.

                JonBJ 1 Reply Last reply
                0
                • JonBJ JonB

                  @ahsan737
                  Still don't understand! How does "a widget adapt to the changes made in the previous 5 widgets", what does that mean? You have to do whatever to pick stuff up from other widgets (pages?) if you want those copied into another widget (page)? Is that what you asking about??

                  Maybe show some code?

                  ahsan737A Offline
                  ahsan737A Offline
                  ahsan737
                  wrote on last edited by
                  #8
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • ahsan737A ahsan737

                    @JonB the application is in a flow. a user is being asked to input parameters one by one (first 5 or 6 screens), and then a graph is being plotted (at screen 7) which will take the previous data as input.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #9

                    @ahsan737 said in QStackedWidget: Loading the widget/class object:

                    @JonB the application is in a flow. a user is being asked to input parameters one by one (first 5 or 6 screens), and then a graph is being plotted (at screen 7) which will take the previous data as input.

                    So you have to write code for that, it won't happen "automatically". I don't know what else to say.

                    BTW, if you have 6 pages of prompting the user for input data, and a final page which does something with that information, and you would like the user to be able to navigate forwards and perhaps backwards through the pages changing data (your "flow"), you should perhaps be using QWizard + QWizardPages, https://doc.qt.io/qt-5/qwizard.html + https://doc.qt.io/qt-5/qwizardpage.html.

                    1 Reply Last reply
                    3
                    • ahsan737A ahsan737

                      I am working on a QStackedWidget based application. when the application runs then load all the classes with initial settings. How can I reload the class object when that particular widget is being displayed? because it has to adapt to the settings.

                      A Offline
                      A Offline
                      Alain38 0
                      wrote on last edited by
                      #10

                      Hi @ahsan737,
                      If I understand well your needs, you have two ways:

                      • QStackedWidget emits the signal curentChanged() whether a given widget that is in the stack is displayed (unless for the first one). So you can intercept the signal to update the content of the widget,
                      • When a widget, in the stack, is called, its member showEvent() is called. So, you can override this function to update the display.
                      1 Reply Last reply
                      2

                      • Login

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