I have QTableWidget, and in the second column I want to provide to user a completer feature, how ever, to accomplish this, I attached a QLineEdit to the specified column. Now I am facing a new problem, since my QTableWidget has to be auto grown(when ever user type a character in the widget , a new row inserted to QTableWidget), so, after reading documentation, I found itemChanged(QTableWidgetItem*) SIGNAL may help me.
SO, when ever a user type some thing in the item(say column 2, row 0), I catch the item changed, cast it to QLineEdit, set completer to it, user will be able to see suggestion, a new row inserted.
{
itemEdit = dynamic_cast<QLineEdit*>(item);
Clients client(ui);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer
->setCompletionMode
(QCompleter::PopupCompletion);
itemEdit->setCompleter(completer);
}
connect(ui->billTableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(addRow(QTableWidgetItem*)));
Store::addRow(QTableWidgetItem*)
{
QLineEdit *itemEdit = new QLineEdit;
itemEdit = dynamic_cast<QLineEdit*>(item);
Clients client(ui);
QStringList clients = client.getClients();
completer = new QCompleter(clients, itemEdit);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setCompletionMode(QCompleter::PopupCompletion);
itemEdit->setCompleter(completer);
}
To copy to clipboard, switch view to plain text mode
But this unfrountly cause the application to be exited on signal 11 (core dumped) like the console said. Is there some thing missing?
Bookmarks