PDA

View Full Version : QWizard registerField not seeming to store what is in a QLineEdit Box



parsnips146
6th August 2010, 11:04
Hi

I am trying to create a wizard for my application which will create a new file with specific details filled in. I stored all variables in registerField with a diffrenet name, i can access the values from a spin box later in the wizard but cannot access any values from the QLineEdit boxes. Any help would be greatly appreciated. the code is inserted below.



tabNamePage::tabNamePage(QWidget *parent) : QWizardPage(parent)
{
setTitle(tr("Tab Selection"));
setSubTitle(tr("Please choose how many tabs "
"and specify the names of each."));

Qt::Alignment Left = Qt::AlignLeft;

numberTabLabel = new QLabel(tr("Number of tabs:"));
numberTabLabel->setMaximumWidth(100);

numberTabSpin = new QSpinBox;
numberTabSpin->setFixedWidth(50);
numberTabSpin->setMinimum(1);
numberTabSpin->setMaximum(10);

tab1 = new QLineEdit;
tab1->setVisible(true);
tab1->setText("Tab 1");
tab1->setFixedWidth(220);
...
registerField("Number of tabs", numberTabSpin);
registerField("tab1", tab1);
registerField("Name of tab 2", tab2);
registerField("Name of tab 3", tab3);
registerField("Name of tab 4", tab4);
registerField("Name of tab 5", tab5);
registerField("Name of tab 6", tab6);
registerField("Name of tab 7", tab7);
registerField("Name of tab 8", tab8);
registerField("Name of tab 9", tab9);
registerField("Name of tab 10", tab10);

QHBoxLayout *Hlayout = new QHBoxLayout;
Hlayout->addWidget(numberTabLabel);
Hlayout->addWidget(numberTabSpin);
Hlayout->setAlignment(Left);

QHBoxLayout *tab1Hlayout = new QHBoxLayout;
tab1Hlayout->addWidget(tab1);
tab1Hlayout->addWidget(tab2);
tab1Hlayout->setAlignment(Left);

...

Vlayout = new QVBoxLayout;
Vlayout->addLayout(Hlayout);
Vlayout->addLayout(tab1Hlayout);
Vlayout->addLayout(tab2Hlayout);
Vlayout->addLayout(tab3Hlayout);
Vlayout->addLayout(tab4Hlayout);
Vlayout->addLayout(tab5Hlayout);
setLayout(Vlayout);

connect(numberTabSpin, SIGNAL(valueChanged(int)),this, SLOT(filltabnameboxes(int)));
}


whichVariablesPage1::whichVariablesPage1(QWidget *parent) : QWizardPage(parent)
{
QString tab1 = field("tab1").toString();

//QString title ="Variables Selection for ";
setTitle(tab1);
setSubTitle(tr("Specify which Variables you would like to include."));

QHBoxLayout *tab5Hlayout = new QHBoxLayout;
QLabel *tab2 = new QLabel(tab1);
tab5Hlayout->addWidget(tab2);
setLayout(tab5Hlayout);

}

int whichVariablesPage1::nextId() const
{
int tabs = field("Number of tabs").toInt();
if(tabs > 1)
{
return newWizard::Page_whichVariable2;
} else {
return newWizard::Page_conclusion;
}
}


Thanks

James

Tataratata
8th August 2013, 14:57
Hi everbody,

first of all I'm sorry for bringing this thread up again. However, I'm facing the same problem.
I've created a QWizard with several QWizardPages. On the first page I have a QLineEdit. The text entered there is stored using registerField.
However if I try to access this value on the next page an empty string is returned.
This is the way I registered my field:




lineTest = new QLineEdit();
registerField("test", lineTest);



And this is what I do to access the field on the next page:



QString test = field("test").toString();


I'm very grateful for any help.

Thanks a lot,
Tara