You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, March 27th 2013, 11:06pm

how to add and delete the text from dynamically created line edits

Hi,

My question refers to this thread created in 2011....
how to get lineEdit content which is created dynamically?

I would like to modify it so the text can also be deleted with a delete button. I want to add all the text that gets inputted to a database but I want to allow the user to also delete a line input they wish to change.

Here's what I have so far, it adds them to the list widget but with a lot of spacing for some reason...

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void userDialog::on_pushButton_3_clicked()
{
    static int LayoutCount;

    QLineEdit *lineEdit = new QLineEdit;

    ui->gridLayout->addWidget( lineEdit,LayoutCount,0 );

    int iCount = ui->gridLayout->count(); //Total no of LineEdit added on gridLayout dynamically
    QString str;
    for(int i = 0; i < iCount; i++)
    {
            QLayoutItem* pLine = ui->gridLayout->itemAt(i);
            QLineEdit* pLineEdit = (QLineEdit*)pLine->widget();
            str = pLineEdit->text();
            ui->listWidget->addItem(str);

            qDebug() << str;
    }

}


Plz help...