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. QWizard and QWizardPage
Forum Updated to NodeBB v4.3 + New Features

QWizard and QWizardPage

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.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.
  • D Offline
    D Offline
    DarkRoast
    wrote on last edited by
    #1

    Hi all

    I am making a wizard.

    My problem is that on the intro page the user selects one or more checkboxes. The next Wizardpages are determined of how many checkboxes the user checked

    ex the user checks three checkboxes then three Wizardpages should be added to the wizard, i.e my problem is how can I let the wizardPage add a page to the wizard. The wizard is dynamic and not static (linear non-linear) as in the examples given by Qt

    How woud I solve this ?

    Thanks
    DarkRoast

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      The options of the users are limited, so you could create all the QWizardPage that your QWizard may need to show and then just switch between them, based on what the user has chosen.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DarkRoast
        wrote on last edited by
        #3

        Hi Josue

        It is true that the options are limited. I found a solution but I don't know if its elegant here it is:

        @void IntroPage::CheckBoxClicked(bool checked) //SLOT for checkbox clicked(bool) SIGNAL
        {
        QCheckBox box = (QCheckBox)sender();

        if(box->objectName() == "Monday")
        {
            CheckBoxClickedHelper("Monday", "Monday sub", checked, box, this);
        }
        else if(box->objectName() == "Tuesday")
        {
            CheckBoxClickedHelper("Tuesday", "Tuesday sub", checked, box, this);
        }
        

        }

        void IntroPage::CheckBoxClickedHelper(const QString &title,
        const QString &subtitle,
        bool checked,
        QCheckBox *box,
        QWidget *parent)
        {
        if(checked)
        {
        TrainingDay *day = new TrainingDay(title, subtitle, parent); //WizardPage
        int id = wizard->addPage(day); // TODO sort after weekday

            QAbstractButton *next = wizard->button(QWizard::NextButton);
            next->setEnabled(true);
            next->setVisible(true);
        
            map.insert(box, id);
        }
        else
        {
            wizard->removePage(map.value(box));
            map.remove(box);
        }
        

        }@

        It works I just thought there was an easier way...

        BR
        DarkRoast

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Well, I've used QWizard only once, moment which I had to subclass QWizard and some of my QWizardPage too, mainly to get more control. I think an easy or more elegant way depends on what you want to do and how you judge your code. I recommend you to read all the "QWizard":http://qt-project.org/doc/qt-4.8/qwizard.html and "QWizardPage":http://qt-project.org/doc/qt-4.8/qwizardpage.html references to get a better idea about all the options you have.

          This example could help you too: http://qt-project.org/doc/qt-4.8/dialogs-licensewizard.html

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            I think the best way to go forward is to make your checkboxes available as fields in the wizard (read the documentation on those!). Then, subclass QWizard, and reimplement the nextId() function. That way, you can control which page is the next page. As you can access fields from the wizard as well, you can find access the values of the checkboxes from that function, and return the right value accordingly.

            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