Hi,

My question refers to this thread created in 2011....
http://www.qtforum.org/article/36821...namically.html

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...
Qt Code:
  1. void userDialog::on_pushButton_3_clicked()
  2. {
  3. static int LayoutCount;
  4.  
  5. QLineEdit *lineEdit = new QLineEdit;
  6.  
  7. ui->gridLayout->addWidget( lineEdit,LayoutCount,0 );
  8.  
  9. int iCount = ui->gridLayout->count(); //Total no of LineEdit added on gridLayout dynamically
  10. QString str;
  11. for(int i = 0; i < iCount; i++)
  12. {
  13. QLayoutItem* pLine = ui->gridLayout->itemAt(i);
  14. QLineEdit* pLineEdit = (QLineEdit*)pLine->widget();
  15. str = pLineEdit->text();
  16. ui->listWidget->addItem(str);
  17.  
  18. qDebug() << str;
  19. }
  20.  
  21. }
To copy to clipboard, switch view to plain text mode 

Plz help...