PDA

View Full Version : Problem with registerField() in a simple implementation of QWizard



Momergil
31st March 2013, 21:17
Hello!

I'm trying to implement a QWizard in my software that should only appear in the first time it's initialized after installation. For that I'm trying to implement that QWizard in the easy way as first shown in the Qt Documentation regarding the QWizard class.

The problem is that after the execution of the wizard, the config set by the user should be stored for that software using QSettings. So I was trying to figure out how could I take the QWizardPages' QLineEdit and etcs info so it could be stored and it seems the only possibile way is by using fields.

So tried to use it and I found the problem of using protected functions:



QWizardPage *createUserData()
{
QWizardPage *page = new QWizardPage;
page->setTitle("User data");

QLabel *label = new QLabel("Fill the following spaces with your personal data.");
label->setWordWrap(true);

QLabel *spaceLabel = new QLabel("");

QLineEdit *LE_Username = new QLineEdit();
LE_Username->setPlaceholderText("Fill your username here");
LE_Username->setObjectName("LE_Username");

QLineEdit *LE_Undefined = new QLineEdit("");
LE_Undefined->setPlaceholderText("Nothing to be written here yet.");

registerField("LE_Username",LE_Username->window()); //Don't accept

QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(label);
layout->addWidget(spaceLabel);
layout->addWidget(LE_Username);
layout->addWidget(LE_Undefined);
page->setLayout(layout);

return page;
}


My question is: is there a way to do what I want without having to implement "classed" QWizardPage? If not, could you please give me a more comple example of how to do it? (I'm not sure if I actually understood how to implement it in accord to the Qt Documentation's example.

Thanks,

Momergil