View Full Version : how to access LINE EDIT'S value
BalaQT
20th August 2009, 08:04
im using the following steps to create LINE EDITS
void DynamicControls::createLineEdit(QString Wstr,QString WTip,int x,int y)
{
lineEdit=new QLineEdit(Wstr);
lineEdit->setToolTip(WTip);
layout->addWidget(lineEdit,x,y);
}
from main im creating LINEEDITS BY FOLLOWING CODE
main()
{
w.createLineEdit("id","id",1,1);
w.createLineEdit("name","name",2,2);
//here i want to access id.text, name.text
}
how can i access in main?
id's value and name value?
pls guide me
Bala
spirit
20th August 2009, 08:27
put you lineedits in a QMap or QHash.
...
QMap<QString, QLineEdit *> lineEdits;
lineEdits.insert("id", new QLineEdit(this));
...
QLineEdit *le = lineEdits.value("id");
if (!le)
return;
le->setText("text");
...
nish
20th August 2009, 08:29
in your DynamicControls class make function that will return the linedit pointer... then you can use w.getlinedit1->text()
EDIT: i m late
yogeshgokul
20th August 2009, 08:36
Set this property @ the time of creating line edits.
yourLineEdit->setAccessibleName("anyNameWithID");
And find these line edits like this:
QLineEdit *le = parentWidget->findChild<QLineEdit *>("LineEdit1");
yogeshgokul
20th August 2009, 09:05
OMG !! I must be too slow.:crying::crying:
spirit
20th August 2009, 09:07
OMG !! I must be too slow.:crying::crying:
why? you example is good too. :)
yogeshgokul
20th August 2009, 09:25
why? you example is good too. :)
:crying::crying::(
I am talking about my typing speed. Until I type my answer this post got 2 answers already.
BalaQT
20th August 2009, 10:54
in your DynamicControls class make function that will return the linedit pointer... then you can use w.getlinedit1->text()
how to return a pointer?
existing coding:
void DynamicControls::createLineEdit(QString Wstr,QString WTip,int x,int y)
{
lineEdit=new QLineEdit(Wstr);
lineEdit->setToolTip(WTip);
layout->addWidget(lineEdit,x,y);
}
and what will be the function call frm main?
exist code
w.createLineEdit(str,str,1,1);
Thanks
Bala
spirit
20th August 2009, 10:58
void DynamicControls::createLineEdit(const QString &Wstr, const QString &WTip,int x,int y)
{
lineEdit=new QLineEdit(Wstr);
lineEdit->setToolTip(WTip);
layout->addWidget(lineEdit,x,y);
lineEdit->setObjectName("someUniqueId");
}
QLineEdit DynamicControls::lineEdit(const QString &uniqueId) const
{
return findChild<QLineEdit *>(uniqueId);
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.