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) :
    QStackedWidget(parent)
    {
    QWidget
    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);

    connect(m_pComboBox,SIGNAL(activated(int)),this,SLOT(setCurrentIndex(int)));

    }
    @

    on my wp1 constructor I have 2 buttons like this:

    @

    _b1->setText(QString::fromUtf8("1. OptionA."));
    _b1->setMinimumSize(MAX_WIDTH,MAX_HEIGH);
    _b1->setMaximumSize(MAX_WIDTH,MAX_HEIGH);
    _b2->setText(QString::fromUtf8("2. OptionB."));
    _b2->setMinimumSize(MAX_WIDTH,MAX_HEIGH);
    _b2->setMaximumSize(MAX_WIDTH,MAX_HEIGH);
    
    this->getLayout()->addWidget(_b1);
    this->getLayout()->addWidget(_b2);
    

    @

    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":http://www.codeprogress.com/cpp/libraries/qt/showQtExample.php?index=279&key=QStackedWidgetChangeCurrentPage (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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.