Filter a QListView with the content of a QLineEdit
-
Hi all
My QListView looks like this:

Now I want to filter the first column (Projekt) to the content of a QLineEdit.
void MainWindow::on_txt_projekt_2_textEdited(const QString &arg1){ extern QStandardItemModel globalEtiketten; QSortFilterProxyModel tempmodel; tempmodel.setSourceModel(&globalEtiketten); tempmodel.setFilterCaseSensitivity(Qt::CaseInsensitive); tempmodel.setFilterKeyColumn(0); tempmodel.setFilterWildcard(arg1); ui->etikettenView->setModel(&tempmodel); }But after pressing for example "4" in the QLineEdit, the table is empty.
As the code gets compiled without error, I think I have given some parameter wrong. Who can tell me which one?
Thank you
Thomas -
Hi all
My QListView looks like this:

Now I want to filter the first column (Projekt) to the content of a QLineEdit.
void MainWindow::on_txt_projekt_2_textEdited(const QString &arg1){ extern QStandardItemModel globalEtiketten; QSortFilterProxyModel tempmodel; tempmodel.setSourceModel(&globalEtiketten); tempmodel.setFilterCaseSensitivity(Qt::CaseInsensitive); tempmodel.setFilterKeyColumn(0); tempmodel.setFilterWildcard(arg1); ui->etikettenView->setModel(&tempmodel); }But after pressing for example "4" in the QLineEdit, the table is empty.
As the code gets compiled without error, I think I have given some parameter wrong. Who can tell me which one?
Thank you
Thomas@Thomas-63 said in Filter a QListView with the content of a QLineEdit:
QSortFilterProxyModel tempmodel;
Basic c++ - what's the lifetime of this object?
-
T Thomas 63 has marked this topic as solved on
-
Oh, i think it is limited to the function, right?
Would it help to define it as external like the QStandardItemModel??@Thomas-63 please tell us that you have made it a class member variable and not a static.