Hi,
I see that this question is not answered and I have the exact same problem. In the QT Designer's created code, all of the widgets like QLineEdit are created in the setupUi function of the QWizard class and their parents are set to the related QWizardPage. I promoted all of the wizard pages in my wizard and if I try to use "registerField" in the constructor of my class inherited from the QWizardPage, I get "Segmentation fault" in run-time. I assume that's because registerField refers to QLineEdit widgets, which are not yet assigned to this wizard page, since they are created in the wizard's scope!
However, if I try to use registerField in the Wizard's constructor, this time I cannot access the protected method of QWizardPage.
I think, there must be a right way to do this and I am missing something. Otherwise, it would be pointless to use the QT Designer.
The generated code:
ui_Wizard.h
...
class Ui_Wizard
{
public:
PageSP *wizardPage_SP;
...
void setupUi (QWizard *Wizard)
{
...
wizardPage_SP = new PageSP();
wizardPage_SP
->setObjectName
(QString::fromUtf8("wizardPage_SP"));
wizardPage_SP->setFocusPolicy(Qt::TabFocus);
lineEdit_SP
->setObjectName
(QString::fromUtf8("lineEdit_SP"));
lineEdit_SP
->setGeometry
(QRect(180,
100,
183,
20));
label_SP
= new QLabel(wizardPage_SP
);
label_SP
->setObjectName
(QString::fromUtf8("label_SP"));
label_SP
->setGeometry
(QRect(180,
80,
183,
16));
....
}
}
...
class Ui_Wizard
{
public:
PageSP *wizardPage_SP;
QLineEdit *lineEdit_SP;
QLabel *label_SP;
QLabel *label_SPInfo;
QFrame *frame_banner;
QLabel *label_logo;
QLabel *label_SP_W;
QLabel *label_req_1;
...
void setupUi (QWizard *Wizard)
{
...
wizardPage_SP = new PageSP();
wizardPage_SP->setObjectName(QString::fromUtf8("wizardPage_SP"));
wizardPage_SP->setFocusPolicy(Qt::TabFocus);
lineEdit_SP = new QLineEdit(wizardPage_SP);
lineEdit_SP->setObjectName(QString::fromUtf8("lineEdit_SP"));
lineEdit_SP->setGeometry(QRect(180, 100, 183, 20));
label_SP = new QLabel(wizardPage_SP);
label_SP->setObjectName(QString::fromUtf8("label_SP"));
label_SP->setGeometry(QRect(180, 80, 183, 16));
....
}
}
To copy to clipboard, switch view to plain text mode
Segmentation Fault Case
My own class using the this Ui_Wizard class:
configwizard.cpp
...
: QWizardPage(parent)
{
registerField("f_SP*",this->findChild<QLineEdit *>("lineEdit_SP"),"plainText", SIGNAL(textChanged()));
}
...
PageSP::PageSP(QWidget *parent)
: QWizardPage(parent)
{
registerField("f_SP*",this->findChild<QLineEdit *>("lineEdit_SP"),"plainText", SIGNAL(textChanged()));
}
To copy to clipboard, switch view to plain text mode
Protected method case
configwizard.cpp
ConfigWizard::ConfigWizard(QWizard *parent)
{
setupUi(this);
this->wizardPage_SP->registerField("f_SP*",this->lineEdit_SP);
}
ConfigWizard::ConfigWizard(QWizard *parent)
{
setupUi(this);
this->wizardPage_SP->registerField("f_SP*",this->lineEdit_SP);
}
To copy to clipboard, switch view to plain text mode
Bookmarks