PDA

View Full Version : How to disable NextButton in QWizard ?



litroncn
26th May 2008, 12:03
Hi!

I am working in Qt 4.3 and have created four pages. In the second page, it has a start pushbutton which is used to calibrate cards. I want to make the start pushbutton enabled and the Qwizard NextButton disabled when initialized. To do this I tried to disable the button in the initializePage() or QWizard’s nextId() funtion, but both do not work.

In Qwizard::nextId():

button(Qwizard::NextButton)->setEnabled(false);

In QwizardPage::initializePage():

QabstractButton *btn = parentHandle->button(Qwizard::NextButton);
Btn->setEnabled(false);

After I called wizard->show(), I do the following:

wizard->button(Qwizard::NextButton)->setEnabled(false);
This can disable the QWizard’s NextButton, but if I call it before wizard->show(), it does not work.
If I connect the start pushbutton click signal to a slot, which is to disable the Qwizard’s NextButton, when I click the button it can disable the QWizard’s NextButton. However, I don’t want it to be disabled when I click the button, only when it is initialized.

Any suggestion will be greatly appreciate!

wysota
26th May 2008, 13:37
Take a look at the docs of QWizardPage::isComplete().

litroncn
27th May 2008, 03:24
Thanks a million, It solved my problem, i did the following:


bool QWizardPage::isComplete()const
{
if (startPushButton->isEnabled()) {
return false;
} else {
return true;
}
}

I am puzzled why I can't disable the QWizard's NextButton in QWizardPage::initializePage(). I did the following:

QAbstractButton *button = wizard()->button(QWizard::NextButton);
button->setEnabled(false);

If you have any suggestions why this is the case, I'd be interested to hear the reason!
Any help would be appreciated!

wysota
27th May 2008, 08:05
Maybe the button gets enabled right after you disable it?