hello anyone,
I 'am using Qt-4.2
I have a problem with QList in use with QListWidget.
I cannot add new item to my QList.
I declared in my header.
private:
QList<QString> list;
private:
QList<QString> list;
To copy to clipboard, switch view to plain text mode
In my implentation file.
list.append("Geert");
QList<QString>::iterator i;
for (i = list.begin(); i != list.end(); ++i){
listWidget->insertItem(0, *i);
}
list.append("Geert");
QList<QString>::iterator i;
for (i = list.begin(); i != list.end(); ++i){
listWidget->insertItem(0, *i);
}
To copy to clipboard, switch view to plain text mode
This works fine i see the name Geert in my listWidget.
Now i want to add a another name to my Qlist through a naamDialog .
Here is a extract of the implentation file in the add function.
{
naamDialog dlg(this);
if( dlg.
exec() == QDialog::Accepted ) {
for (int row = 0; row < list.count(); ++row) {
naam = dlg.leNaam->text();
list.append(naam);
}
}
{
naamDialog dlg(this);
if( dlg.exec() == QDialog::Accepted ) {
QString naam = dlg.leNaam->text();
for (int row = 0; row < list.count(); ++row) {
naam = dlg.leNaam->text();
list.append(naam);
}
}
To copy to clipboard, switch view to plain text mode
It compile with no error's but when i run the application than the name is not added to the QList.
Can you tell what i'am doing wrong in my code.
Thanks in advance.
Bookmarks