PDA

View Full Version : get data from QWizardPages - which signal?



dotjan
14th February 2012, 03:20
Hi all,

using QtCreator I have created a QWIzard class and form and promoted the pages to my QWizardPage classes, one for each page. So far so good. Honestly I do not know if it is the proper way do to this, but it is the only one I could find out and seems to work. Is it right?

Anyway the main question I have is about getting the data the user inserts in these pages (for example in the lineEdit widgets), in order to store it on disk, using QSettings in my case. With other forms I simply connect the signal from a button to a slot, but in this case I can not figure out how to connect the signal from the Next and Finish buttons.

Thanks,
Jan

ChrisW67
14th February 2012, 04:46
Building a wizard with Designer is done the way you describe. You generally cannot do all the plumbing without resorting to code.

You can pass data around within the wizard using registered fields. These fields should be available when the user clicks finished and the accepted() signal is emitted by the wizard.

dotjan
14th February 2012, 11:48
Great, for the QWizard object I have connected the accepted() signal to the slot getData():



connect(this, SIGNAL(accepted()), this, SLOT(getData()));

which is then implemented to get the data:


void ProfileWizard::getData()
{
QString name = field("ProfileName").toString();
.....
}

This worked for me. I could also use the QWizardPage::initializePage () function in the "next" page to get data from the "previous page" but I had the problem I could not figure out how to get data from the last page. A possible workaround was to have one more page to be the final one without getting any data. Of course, the suggested solution does make much more sense.

Thanks,
Jan