Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to completely disable or hide Back button in QWizard?

Tags:

qt

qt4

wizard

I want to disable or hide Back button in QWizard dialog. How can I do it?

like image 432
Dmitriy Avatar asked Jan 31 '12 00:01

Dmitriy


2 Answers

I've looked at Qt's sources and found out that it's possible to hide Back button by creating custom button layout and ommiting Back button in the list:

  QList<QWizard::WizardButton> button_layout;
  button_layout << QWizard::HelpButton << QWizard::Stretch <<
                   QWizard::NextButton << QWizard::CustomButton1 <<
                   QWizard::CancelButton;
  this->setButtonLayout(button_layout);

I hope this will save some time to somebody.

P.S.

AFAIU to avoid using QTimer it is needed to modify QWizard source code. The easies way will be to add a virtual function virtual void buttonsUpdated(); and call it from the end of QWizard's: void QWizardPrivate::_q_updateButtonStates() Then reimplement this buttonsUpdated() in your QWizard sublass and disable Back button there.

like image 121
Dmitriy Avatar answered Nov 03 '22 00:11

Dmitriy


Calling

QWizard::button(QWizard::BackButton).hide()

in

QWizard::onCurrentIdChanged(int)

worked for me (in PyQt4).

This effectively hides the back button again on every wizard page, but it achieves the desired effect.

like image 44
Patrick Böker Avatar answered Nov 03 '22 00:11

Patrick Böker