Solved Doubts with the isComplete function in the QWizard and QWizardPage
-
Hi,
I have a couple of doubts with the QWizard and QWizardPage objects.
This is the QWizard definition:
MachineWizard::MachineWizard(QWidget *parent) : QWizard(parent) {
.
.
setPage(Page_Name, new MachineNamePage(this));
.
.
}And this is the QWizardPage:
MachineNamePage::MachineNamePage(QWidget *parent) : QWizardPage(parent) {
.
.
descriptionNameLabel = new QLabel(tr("Select name and operating system for your new machine."));
descriptionNameLabel -> setWordWrap(true);
.
machineNameLabel = new QLabel(tr("Name") + ":");
machineNameLineEdit = new QLineEdit();
.
.
.
}How can I enable/disable the next button when the machineNameLineEdit aren't empty?
I saw that in the QWizardPage shows the isComplete function.(https://doc.qt.io/qt-5/qwizardpage.html#isComplete)
But I don't know how to implement that function.Can anybody show an example of the isComplete function must be?
Thanks.
-
Hi and welcome to devnet,
Since your requirement seems to be "mandatory fields" like, take a look at the related paragraph in QWizard's documentation.
-
Hi SGaist,
Thanks for the info. Yes, with the instrucction:
registerField("machine.name*", machineNameLineEdit);
It's enough to control the activation of the next button.
So, what's the difference between registerField and "isComplete" method? -
Like it's written in the documentation:
QWizard's mandatory field mechanism is provided for convenience. A more powerful (but also more cumbersome) alternative is to reimplement QWizardPage::isComplete() and to emit the QWizardPage::completeChanged() signal whenever the page becomes complete or incomplete.
The only link between both methods here is the star.
-
Thanks for your help.
I solved my problem. :) -
Great,
Then please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)