RanH
RanH

Reputation: 852

How to use CustomButton to change QWizard page in Qt?

I have a QWizard with 2 custom buttons (on top of the Back\Next buttons).

I wish that a click on my custom button will change to another QWizardPage.

How do I do that? Thanks

Upvotes: 1

Views: 1207

Answers (1)

miped
miped

Reputation: 36

That would be doable by connecting the custom buttons clicked signal with a slot which handles moving to next page.

QWizard wizard;

wizard.setButtonText(QWizard::CustomButton1, "Custom button");
wizard.setOption(QWizard::HaveCustomButton1, true);

QObject::connect(&wizard, &QWizard::customButtonClicked, [&]
{
    wizard.next();
});

The code above would create a wizard with a custom button which would function like the default "next" button. If you want to create a dynamic (as opposed to linear wizard which it is by default) you would need to reimplement QWizard::nextId(). Please see:

https://doc.qt.io/qt-5/qwizard.html#nextId

Upvotes: 2

Related Questions