Create QLineEdit on QListWidget when double clicked
-
So here I add a
QListWidgetto aQTableWidgetin a function in mainwindow.cppQListWidget *listWid = new QListWidget; ui->tableWidget_2->setIndexWidget(ui->tableWidget_2->model()->index(4, (n - m_list.begin())), listWid);//ignore n-m_list.begin()And here I want to add a QLineEdit when user double clicks into an empty area of that list widget.
So I tried to use this:
connect(listWid, SIGNAL(doubleClicked(listWid)), listWid, [&](){ QLineEdit *as = new QLineEdit; listWid->addItem(as->text()); });But it generates "No matching member function for call to 'connect'"
How can I solve this? thanks in advance.
-
Hi,
Two things that stand out:
- use the function pointer version of connect to use it with a lambda
- your lambda will just add an empty item to your list widget and leak a QLineEdit object every time you call it.