PDA

View Full Version : lineedit fill in new dialog window.



mkarakaplan
6th October 2007, 23:40
I created a form with designer-qt4 and open in myqtapp.cpp

myForm *dialog2 = new myForm;
dialog2->show();

but i want fill a lineedit in new opened form. Like this.
lineEdit_recordid->setText("315");

and i get following error.
myqtapp.cpp:41: error: ‘lineEdit_recordid’ was not declared in this scope
make: *** [myqtapp.o] Error 1

what can i use?

jpn
7th October 2007, 07:00
Provided that "lineEdit_recordid" was placed in Designer, it's a private member of myForm. You could do it for example like this:


class myForm
{
...
public:
void setRecordId(const QString& id);
...
};

void myForm::setRecordId(const QString& id)
{
lineEdit_recordid->setText(id);
// or
// ui.lineEdit_recordid->setText(id);
}

// usage:
dialog2->setRecordId("315");