2
votes

I have a QWizard and I need to perform certain actions each time a wizard page becomes visible. Currently I am doing this in the validateCurrentPage function but I have realised that it is only called when the Next button is pressed, not the Back button.

I've tried the currentIdChanged and customButtonClicked signals but these don't get called either.

Any idea how I can respond to a wizard page that is shown after the Back button is pressed? I must be missing something simple...

Thanks, Alan

Edit: Added code and compiler error as requested by cmannett85

QAbstractButton *backButton = button(QWizard::BackButton);
connect(backButton, SIGNAL(clicked()), this, SLOT(backClicked));

The full error is:

Error 1 error C2664: 'bool QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)' : cannot convert parameter 1 from 'QAbstractButton *' to 'const QObject *'

1
This error doesn't really make sense unless you forgot to add "#include <QAbstractButton>".darron
Thanks. That was indeed the cause of the error... sorry I didn't spot it myself.Alan Spark

1 Answers

2
votes

Get the back button with QAbstractButton *QWizard::button (WizardButton which) and connect it to a slot.

Example:

QAbstractButton *backButton = wizard->button(QWizard::BackButton);
connect(backButton, SIGNAL(clicked()), this, SLOT(backClicked()));