How to get lineEdit content which is created dynamically?
-
In my program i'm creating lineEdit widget dynamically whenever a user enters "ADD" button.
But i'm not able to access the text of that dynamically created lineEdit.
my code is as follows...
@ on_pushButton_ADD_clicked()
{
QLineEdit *lineEdit = new QLineEdit;
QLabel *label = new QLabel;
ui->gridLayout->addWidget( label,LayoutCount,0 );
ui->gridLayout->addWidget( lineEdit,LayoutCount,1 );
.................
}@for accessing the dynamically created lineEdit i'm trying as follows..
@KeyList.append(ui->gridLayout->lineEdit->text());
@But i'm getting error....
Please help me....HOW CAN I ACCESS lineEdit->text? -
Layouts do not contain widgets, but layout items.
So, if you want to access the widgets, first browse through the list of layout items, and access the widget or child layout in the item. -
Better yet, when you create the line edit, simply keep a pointer to it in some kind of suitable data structure (a QList, for instance).
-
[quote author="Andre" date="1319011099"]Better yet, when you create the line edit, simply keep a pointer to it in some kind of suitable data structure (a QList, for instance).[/quote]
please may i know how can i do that...? some format atleast....
-
[quote author="aurora" date="1319013560"]
please may i know how can i do that...? some format atleast....[/quote]@
QList<QLineEdit *> lineEditList;
lineEditList.add(lineEdit);
@ -
[quote author="Volker" date="1319028037"]
[quote author="aurora" date="1319013560"]
please may i know how can i do that...? some format atleast....[/quote]@
QList<QLineEdit *> lineEditList;
lineEditList.add(lineEdit);
@
[/quote]THANKS A LOT...IT HELPED ME...:)
but now using combox also....
so i declared like this...
@QList<QComboBox *> TagList;@
but getting error saying that "'ComboBox' was not declared in this scope"!!!! -
So... Did you make sure it is declared then? Try to put
@
#include <QtGui/QComboBox>
@
at the top of the file where you get this complaint.