Hi,
I want to know how to do a hide/show filter on a QTableView. In the same way as the KDE applications.
I've tried this code but it's too slow:
void MainWindow
::on_lineEdit_textChanged(const QString &text
){ FilterThread thread(text, queryModel, tableView);
thread.run();
}
void MainWindow::on_lineEdit_textChanged(const QString &text){
FilterThread thread(text, queryModel, tableView);
thread.run();
}
To copy to clipboard, switch view to plain text mode
m_text=text;
m_model=model;
m_table=table;
}
void FilterThread::run(){
for(int i=0;i<m_model->rowCount();i++){
QString title
=m_model
->data
(m_model
->index
(i,
3)).
toString();
m_table->setRowHidden(i, title.indexOf(m_text, 0, Qt::CaseInsensitive)==-1);
}
}
FilterThread::FilterThread(QString text, QueryModel *model, QTableView *table, QObject *parent):QThread(parent){
m_text=text;
m_model=model;
m_table=table;
}
void FilterThread::run(){
for(int i=0;i<m_model->rowCount();i++){
QString title=m_model->data(m_model->index(i, 3)).toString();
m_table->setRowHidden(i, title.indexOf(m_text, 0, Qt::CaseInsensitive)==-1);
}
}
To copy to clipboard, switch view to plain text mode
Thank's
Bookmarks