Control of qwizard's next button
Qwizard is the wizard class of QT. During the wizard process, you can use the registerfield function to register fields for global access, and you can use four methods to control the availability of the next or complete button:
The first method is the iscomplete function, which is applied to the qwizardpage to control the availability of the "Next" or "finish" button on a single Wizard Page. The function is as follows:
1 |
bool QWizardPage::isComplete () const [ virtual ] |
The following is the implementation of iscomplete. The source code is from
Http://doc.qt.nokia.com/qq/qq22-qwizard.html#validatebeforeitstoolate
First, implement the qwizardpage: iscomplete () function again.
1 |
bool SailingPage::isComplete() const |
3 |
return field( "sailing" ).toDate().dayOfWeek() |
Connect the signal of the input box or other objects to be monitored to the qwizardpage: completechanged () signal.
1 |
connect(sailing, SIGNAL(selectionChanged()), this , SIGNAL(completeChanged())); |
Of course, you can also execute the qwizardpage: completechanged () signal by yourself, that is, compile the check function and then execute the signal:
Method 2: hasacceptableinput function, used for qlineedit. If hasacceptableinput is false, the button will become grayed out.
1 |
bool hasAcceptableInput () const |
The third method is the registerfield function. The first parameter name is followed by an asterisk, for example, field *. This ensures that if this field is not filled in, the next button is grayed out.
1 |
void QWizardPage::registerField ( const QString & name, QWidget * widget, const char * property = 0, const char * changedSignal = 0) |
The fourth method is to re-implement the bool qwizardpage: validatepage () function, which can complete the function defined by the function when you click the next or complete button. Of course, this includes verifying this type of thing.