PDA

View Full Version : QWizard - mandatory fields



slava
11th February 2008, 09:41
Per the manual the * make the field in QWizardPage manadory, i.e. the button "Next" enables only when that field is filled.

I do:

registerField("field*", lineEdit);

and that works fine with QLineEdit but the same thing doesn't fly with QTextEdit. I do:

registerField("field*", textEdit, "plainText");

(I have to add "plainText" since textEdit is not a default property of QWizardPage)
and that doesn't work - the button "Next" does not get enabled when that textEdit gets filled.
I've tried:

registerField("field*", textEdit, "plainText", "textChanged");

didn't help either...

jpn
11th February 2008, 09:53
registerField("field*", textEdit, "plainText", SIGNAL(textChanged()));

slava
11th February 2008, 10:57
Thank you very much, this is working now.
Can I ask one more quesiton?
Is it possible to change mandatority of the fielf later as a condition from some event? Like if a user chooses "Yes" in the comboBox, the field is mandatory, if user chooses "No", the field is not madatory. I have tried:



Page::Page (QWidget *parent)
: QWizardPage(parent)
{
.....
registerField("field*", lineEdit);
....
}


void Page::event()
{
if (comboBox->currentIndex() == 0) registerField("field*", lineEdit)
else registerField("field", lineEdit)
}

... i.e. put the "field" with the * or without it?

jpn
11th February 2008, 11:09
It might prove to be easier to simply connect QComboBox::currentIndexChanged() to QWizardPage::completeChanged() and re-implement QWizardPage::isComplete().

slava
12th February 2008, 10:02
Thank you very much! :)

And the last question, please....
I have sorted out those mandatory fields thing, but the last thing I need to resolve is the size of the pages.
Whatever size I put for the QWizardPages to be it does not change anything, I can not strach the window by a mouse and there is no maximize button at the top of the window.
I have tried
resize(...., ...)
etc, but nothing helped...

jpn
12th February 2008, 10:21
You could try passing Qt::Window as second parameter to QWizard constructor if you want to make it appear as an ordinary window instead of a dialog.

slava
12th February 2008, 10:57
sorry, how do I do that, in the header file?

jpn
12th February 2008, 11:05
QWizard wizard(parent, Qt::Window); // <---
wizard.addPage(...);
wizard.addPage(...);
...
wizard.exec();

slava
12th February 2008, 11:17
I did it. The "maximize" button appeared but when I press it it streaches out the window to the maximum only vertically, the horizontal size still stays the same :confused:

jpn
12th February 2008, 11:21
Did you set any maximum sizes (widths) and/or did you adjust any size policies?

Edit: Oh, and which platform are you working on? Could you edit your user profile to indicate that? Thanks.

slava
12th February 2008, 11:51
not for the whole form. I have some size policies for the widgets and spacers inside the form so they streaches out correctly but no size policies for the whole form.
I did the pages in QT Designer, then converted them by uic and inserted the result into my program. In the Designer in the Form Preview I have the maximize button and it work fine, but when I insert it to the overall program I get that trouble.
I work on Windows for now.

jpn
12th February 2008, 12:23
I can assure you that it works with minimal test wizard. Did you subclass QWizard? If so, I'd suggest trying out with a plain QWizard to see if your subclass does something faulty. Furthermore, if it doesn't resolve the problem, try leaving out page by page to see which page could cause it.

slava
12th February 2008, 13:52
I found it! It was the pictures at the top and at the left which was set by setPixMap, they were limiting the sizes of the window, once I took those off the window got able to be any size.
thank you! :)