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. [Solved] How to pass information between wizardpages without widgets

[Solved] How to pass information between wizardpages without widgets

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.5k 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.
  • R Offline
    R Offline
    roseicollis
    wrote on last edited by
    #1

    Hi!

    I am making a GUI app with wizard structure and I have:

    • the main.cpp
    • the class MainWindow : public QMainWindow basic class
    • class BaseWizard : public QWizard
    • class BasePage : public QWizardPage
    • all the pages(wp1, wp2, wp3 …) like this: class WP1 : public BasePage (they inherit from BasePage)

    Then in wp1 I have 2 big buttons which you can focus the with tab. If you press 'L' when button1 has focus, you go to wp2, and if the focus is on button2, you go to wp3.

    Now I want to know if the user choose to go to wp2 or wp3, so I decided to put a var (int iA; ) in Basepage (cause its common to all pages) and change iA's value on the page I want to, so I have:

    On basepage.h:

    @public:
    void setA(int i);
    int getA() {return iA;};
    private:
    int iA;@

    on wp2.cpp:

    @void WP2::initializePage()
    {
    BasePage::setA(0);
    }@

    on wp3.cpp:

    @void WP3::initializePage()
    {
    BasePage::setA(1);
    }@

    So I know that if getiA() returns 0 means the user chose the first option, and if it returns 1 the user chose the second.

    The problem is that setA() works fine but then the var iA gets any number lately, and I don't make any other setA()... so when I am on w5 and I want to do a BasePage::getA() it returns 0 or 4 or 5 or... instead of (in case the user chose the second button) ...1 .

    Any idea of why? Any idea of how can I pass the information throw wizardpages?

    I know that you can registerfield() but that is only for wdgets like lineedits, so it doesn't work here.

    Thanks.

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

      Hi,

      registerField can be used for other widgets. Take a look again at the signature, you can give it a property name and changedSignal, so it means that you can use it with custom widget having their own properties

      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
      • R Offline
        R Offline
        roseicollis
        wrote on last edited by
        #3

        Hi,

        Mmmm I have see what you say:
        @void QWizardPage::registerField ( const QString & name, QWidget * widget, const char * property = 0, const char * changedSignal = 0 )@

        So I suppose that I have to do something like this to get the focus change:

        @registerField("First_Option", button1, focus , somesignalhere);@

        But I can't see how does it works with or without the 'supposed' signal.

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

          when you call field("First_Option") it will get the value of the focus property of button1

          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
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            A trick you can also employ with registerFields is to realize that it works with a property on any widget, and that QWizardPage is a widget too... So, if you don't want to or just can't use a widget on the page, you can also use the page itself. Just define your own Q_PROPERTY on it to represent the value you want to share, and register that property.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              roseicollis
              wrote on last edited by
              #6

              Solved! Thank you so much.

              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