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. How to programatically create dynamic pages
Qt 6.11 is out! See what's new in the release blog

How to programatically create dynamic pages

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.8k Views 2 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.
  • A Offline
    A Offline
    AaronKelsey
    wrote on last edited by
    #1

    I am developing a wizard-like application which will have two program flows which are similar. I have created each page as a class which inherits from a widget and they have been added to a QStackedWidget to switch between pages.

    Between the two program flows there are some pages which are very similar to each other but have slight changes, for examples different text etc. Rather than creating two classes (pages) that are nearly identical I would rather use one and dynamically change it depending on which option the user has selected.

    My question is to ask which would be the best approach for this. I have an idea and I would appreciate your feedback.

    I was thinking that I could initialise all the variables in the constructor, and then create two functions OptionA and OptionB. Then if the user selects OptionA it could call OptionA and within that function it would display the appropriate widgets.

    Is this the correct approach or am I completely wrong?

    Thanks.

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

      Hi
      That sounds reasonable to me. The Page would simply be dynamic and setting some text and show/hide some widgets
      depending on previously selection.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AaronKelsey
        wrote on last edited by
        #3

        Would you recommend creating a class that is responsible for handling the flow of the application? potentially a boolean set to true/false for OptionA/OptionB to control which pages to show and which content to show on each page?

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

          Hi
          Well i often use a controller class when using a QStackedWidget to allow
          flexible navigation. Also it allows for different flows if the Controller uses a index list/map to navigate between
          pages and in that way, its easy to have different sequences using the same pages and at the same time
          not coupling the navigation logic to the MainWindow/QStackedWidget parent.
          So yes, if you application have more than one flow, a data driven approach should turn out very
          effective and the flow list could also be used with additional data such as OptionA/B from your case.

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

            Hi,

            Aren't you describing something like a QWizard ?

            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
            1
            • mrjjM mrjj

              Hi
              Well i often use a controller class when using a QStackedWidget to allow
              flexible navigation. Also it allows for different flows if the Controller uses a index list/map to navigate between
              pages and in that way, its easy to have different sequences using the same pages and at the same time
              not coupling the navigation logic to the MainWindow/QStackedWidget parent.
              So yes, if you application have more than one flow, a data driven approach should turn out very
              effective and the flow list could also be used with additional data such as OptionA/B from your case.

              A Offline
              A Offline
              AaronKelsey
              wrote on last edited by
              #6

              @mrjj That sounds exactly like what I would like to do, is it possible for you to supply me with some more information on how I could approach this? possibly some pseudo-code or bullet points?

              What variables would you recommend storing in the controller class and how would you recommend it communicates with the rest of the classes?

              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