Solved Table widget search bar doesnt update the value
-
I'm added the searching bar to my table widget. I searched something then i delete it, wrote another word but table widget doesnt update yourself, it keep the old searching items, and the new one. How can solve this problem
void MainWindow::on_search_editingFinished() { QList<QTableWidgetItem*> arama =ui->tableWidget->findItems(ui->ara->text(), Qt::MatchContains ); for(QTableWidgetItem* item : arama) { qDebug() << ui->ara->text(); ui->tableWidget->setCurrentItem(item); }
-
@suslucoder Does the table contain the new string? Before starting new search you should undo the old one. Else, if the new string cannot be found you will still see the old result.
-
@jsulm yes the new one is on the table.
How can i undo the old one before new search? -
@suslucoder Well, you have to undo ui->tableWidget->setCurrentItem(item); , right? You could use https://doc.qt.io/qt-5/qtablewidget.html#setRangeSelected to deselect everything.
-
@jsulm i've solve it
ui->tableWidget->clearSelection();
is this a wrong usage or might it be a problem?
-
@suslucoder said in Table widget search bar doesnt update the value:
is this a wrong usage or might it be a problem?
This is actually easier than what I suggested.