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. QWizardPage question

QWizardPage question

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 3 Posters 2.2k 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.
  • HoMaH HoMa

    Hi all and thank you for your time.
    For my little db app I want to have a wizard with a page, on which there are two radio buttons and a combo box. The first radio button should be selected by default. The combo box should be disabled -> no problem so far.
    .However: the combo box should be enabled, when the second of the two radio buttons is pressed.
    How can I achieve this?
    Best regards
    Holger

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

    @HoMa said in QWizardPage question:

    How can I achieve this?

    Quite easy actually: connect https://doc.qt.io/qt-5/qabstractbutton.html#toggled from the second radio button to a slot where you then call https://doc.qt.io/qt-5/qwidget.html#enabled-prop on the combo box.

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

    HoMaH 1 Reply Last reply
    4
    • HoMaH Offline
      HoMaH Offline
      HoMa
      wrote on last edited by
      #3

      Wow - that was a quick one! Thanks a lot - I will try this.

      btw: I never read the docu to QAbstractButton before ...

      jsulmJ 1 Reply Last reply
      0
      • HoMaH HoMa

        Wow - that was a quick one! Thanks a lot - I will try this.

        btw: I never read the docu to QAbstractButton before ...

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

        @HoMa said in QWizardPage question:

        QAbstractButton

        It's the base class of QRadioButton
        See "Inherits: QAbstractButton" in https://doc.qt.io/qt-5/qradiobutton.html
        To see everything including inherited methods/properties click on "List of all members, including inherited members".

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

        1 Reply Last reply
        3
        • jsulmJ jsulm

          @HoMa said in QWizardPage question:

          How can I achieve this?

          Quite easy actually: connect https://doc.qt.io/qt-5/qabstractbutton.html#toggled from the second radio button to a slot where you then call https://doc.qt.io/qt-5/qwidget.html#enabled-prop on the combo box.

          HoMaH Offline
          HoMaH Offline
          HoMa
          wrote on last edited by
          #5

          @jsulm
          :( obviously I am not "fluent" enough with signals and slots. Can you check why this does not work (this is in the contructor of the QWizardPage):

          setTitle(qsl("title"));
              rbNew =new QRadioButton(qsl("do this"));
              rbExisting =new QRadioButton(qsl("select that"));
              registerField(qsl("create_new"), rbNew);
              cbCreditors = new QComboBox();
              QVBoxLayout* l =new QVBoxLayout();
              l->addWidget(rbNew);
              l->addWidget(rbExisting);
              l->addWidget(cbCreditors);
              setLayout(l);
              connect(rbExisting, &rbExisting->toggled, this, &this->onExistingCreditor_toggled);
          
          J.HilkJ 1 Reply Last reply
          0
          • HoMaH HoMa

            @jsulm
            :( obviously I am not "fluent" enough with signals and slots. Can you check why this does not work (this is in the contructor of the QWizardPage):

            setTitle(qsl("title"));
                rbNew =new QRadioButton(qsl("do this"));
                rbExisting =new QRadioButton(qsl("select that"));
                registerField(qsl("create_new"), rbNew);
                cbCreditors = new QComboBox();
                QVBoxLayout* l =new QVBoxLayout();
                l->addWidget(rbNew);
                l->addWidget(rbExisting);
                l->addWidget(cbCreditors);
                setLayout(l);
                connect(rbExisting, &rbExisting->toggled, this, &this->onExistingCreditor_toggled);
            
            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #6

            @HoMa said in QWizardPage question:

            connect(rbExisting, &rbExisting->toggled, this, &this->onExistingCreditor_toggled);

            this is not the correct syntax for a function pointer!

            connect(rbExisting, & QRadioButton::toggled, this, &MyClass::onExistingCreditor_toggled);


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            2
            • HoMaH Offline
              HoMaH Offline
              HoMa
              wrote on last edited by
              #7

              I slowly advance ;)

              This

              connect(rbExisting, SIGNAL(toggled()), this, 
              SLOT(onExistingCreditor_toggled()));
              

              compiles, but gives me an error at runtime:

              QObject::connect: No such signal QRadioButton::toggled()
              

              But that was what we got from the QAbstractButton, right?
              One last hint ...?

              jsulmJ 1 Reply Last reply
              0
              • HoMaH HoMa

                I slowly advance ;)

                This

                connect(rbExisting, SIGNAL(toggled()), this, 
                SLOT(onExistingCreditor_toggled()));
                

                compiles, but gives me an error at runtime:

                QObject::connect: No such signal QRadioButton::toggled()
                

                But that was what we got from the QAbstractButton, right?
                One last hint ...?

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

                @HoMa Please read documentation https://doc.qt.io/qt-5/qabstractbutton.html#toggled
                Hint: the signal has a parameter...

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

                HoMaH 1 Reply Last reply
                2
                • jsulmJ jsulm

                  @HoMa Please read documentation https://doc.qt.io/qt-5/qabstractbutton.html#toggled
                  Hint: the signal has a parameter...

                  HoMaH Offline
                  HoMaH Offline
                  HoMa
                  wrote on last edited by
                  #9

                  @jsulm you are right again - but

                  connect(rbExisting, SIGNAL(toggled(bool)), this, SLOT(onExistingCreditor_toggled(bool)));
                  

                  gives me

                  QObject::connect: No such slot QWizardPage::onExistingCreditor_toggled(bool)
                  

                  :/ am I the only one who finds this confusing?

                  jsulmJ 1 Reply Last reply
                  0
                  • HoMaH HoMa

                    @jsulm you are right again - but

                    connect(rbExisting, SIGNAL(toggled(bool)), this, SLOT(onExistingCreditor_toggled(bool)));
                    

                    gives me

                    QObject::connect: No such slot QWizardPage::onExistingCreditor_toggled(bool)
                    

                    :/ am I the only one who finds this confusing?

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

                    @HoMa Because your slot does not have parameters, simply remove "bool"...
                    A slot is allowed to have less parameters than signal (but not the other way around).

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

                    HoMaH 1 Reply Last reply
                    1
                    • jsulmJ jsulm

                      @HoMa Because your slot does not have parameters, simply remove "bool"...
                      A slot is allowed to have less parameters than signal (but not the other way around).

                      HoMaH Offline
                      HoMaH Offline
                      HoMa
                      wrote on last edited by
                      #11

                      @jsulm 1000x thanks that you are so patient.
                      However: this does not do the trick. I tried both ways: with and w/o parameter in the function definition as well as in the connect call.
                      The error mentioned QWizardPage... shouldn't it be about my class (which is derived from QWizardPage)?
                      regards
                      Holger

                      jsulmJ 1 Reply Last reply
                      0
                      • HoMaH HoMa

                        @jsulm 1000x thanks that you are so patient.
                        However: this does not do the trick. I tried both ways: with and w/o parameter in the function definition as well as in the connect call.
                        The error mentioned QWizardPage... shouldn't it be about my class (which is derived from QWizardPage)?
                        regards
                        Holger

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

                        @HoMa Can you show your current connect call and slot declaration? Without code I can't tell you much.

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

                        HoMaH 1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @HoMa Can you show your current connect call and slot declaration? Without code I can't tell you much.

                          HoMaH Offline
                          HoMaH Offline
                          HoMa
                          wrote on last edited by
                          #13

                          @jsulm - you are right, sorry. This is current - but it does not link with an error "undefined reference to vtable" ...

                          class wizNewOrExistingPage : public QWizardPage
                          {
                              Q_OBJECT
                          public:
                              wizNewOrExistingPage(QWidget* );
                              void initializePage() override;
                          public slots:
                              void onExistingCreditor_toggled(bool );
                          ...
                          
                          wizNewOrExistingPage::wizNewOrExistingPage(QWidget* p) : QWizardPage(p)
                          {
                              rbNew =new QRadioButton(qsl("do this"));
                              rbExisting =new QRadioButton(qsl("do other"));
                              registerField(qsl("create_new"), rbNew);
                              cbCreditors = new QComboBox();
                              QVBoxLayout* l =new QVBoxLayout();
                              l->addWidget(rbNew);
                              l->addWidget(rbExisting);
                              l->addWidget(cbCreditors);
                              setLayout(l);
                              connect(rbExisting, SIGNAL(toggled(bool)), this, SLOT(onExistingCreditor_toggled(bool)));
                          }
                          
                          void wizNewOrExistingPage::onExistingCreditor_toggled(bool b)
                          {
                              cbCreditors->setEnabled(b);
                          }
                          
                          jsulmJ 1 Reply Last reply
                          0
                          • HoMaH HoMa

                            @jsulm - you are right, sorry. This is current - but it does not link with an error "undefined reference to vtable" ...

                            class wizNewOrExistingPage : public QWizardPage
                            {
                                Q_OBJECT
                            public:
                                wizNewOrExistingPage(QWidget* );
                                void initializePage() override;
                            public slots:
                                void onExistingCreditor_toggled(bool );
                            ...
                            
                            wizNewOrExistingPage::wizNewOrExistingPage(QWidget* p) : QWizardPage(p)
                            {
                                rbNew =new QRadioButton(qsl("do this"));
                                rbExisting =new QRadioButton(qsl("do other"));
                                registerField(qsl("create_new"), rbNew);
                                cbCreditors = new QComboBox();
                                QVBoxLayout* l =new QVBoxLayout();
                                l->addWidget(rbNew);
                                l->addWidget(rbExisting);
                                l->addWidget(cbCreditors);
                                setLayout(l);
                                connect(rbExisting, SIGNAL(toggled(bool)), this, SLOT(onExistingCreditor_toggled(bool)));
                            }
                            
                            void wizNewOrExistingPage::onExistingCreditor_toggled(bool b)
                            {
                                cbCreditors->setEnabled(b);
                            }
                            
                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #14

                            @HoMa said in QWizardPage question:

                            "undefined reference to vtable"

                            Do a complete rebuild: remove build folder, run qmake and build.

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

                            HoMaH 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @HoMa said in QWizardPage question:

                              "undefined reference to vtable"

                              Do a complete rebuild: remove build folder, run qmake and build.

                              HoMaH Offline
                              HoMaH Offline
                              HoMa
                              wrote on last edited by
                              #15

                              @jsulm exactly ! I just found out no my own. That is strange.

                              Anyhow: great! Learned a lot on signals and slots - Thanks a lot!

                              1 Reply Last reply
                              3

                              • Login

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