Nominate our 2022 Qt Champions!

Transferring a QWizard sctructure to a QStackedWidget

  • Hi,

    I have made a gui app with a QWizard structure (with its QWizardPages: wp1, wp2 ...). Now that its more or less finished I found out that there is a QStackedWidget which is a better option for my App because I need to enable/disable the QWizard buttons depending on the page but this is not possible (At least not with ALL the buttons including next and back which always remind there even if you put a setvisible(false) or hide() or enable(false)...

    So I added to my project a new Qt class:

    class StackedWidget : public QStackedWidget

    And then, put this on the constructor:
    StackedWidget::StackedWidget(QWidget parent) :
    centralWidget = new QWidget();
    QComboBox *m_pComboBox = new QComboBox();

    addWidget(new WP1);
    addWidget(new WP2);
    addWidget(new WP3);

    m_pComboBox->addItem("Page 1");
    m_pComboBox->addItem("Page 2");
    m_pComboBox->addItem("Page 3");

    //The idea here is to add the wizard and the combobox to a layout so they appear in order, but couldn't find how
    //QVBoxLayout *layout = new QVBoxLayout;
    // layout->addWidget(m_pComboBox);



    on my wp1 constructor I have 2 buttons like this:


    _b1->setText(QString::fromUtf8("1. OptionA."));
    _b2->setText(QString::fromUtf8("2. OptionB."));


    So what I don't know is how to see 2 things on the screen: the wp1 and, downside, the combobox. Like this example: "Example": (my wp1 would go where the button is and the combobox where the other combobox)

    And another thing: do you know why do the 2 buttons appear at the bottom of the window and not at the top? I mean.. now is like if there were gravity and buttons go as down as they can while before, with QWizard they were as 'up' as they can so I had free space on the bottom.

    Thank you!

Log in to reply