xgoan
21st December 2006, 14:52
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();
}
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);
}
}
Thank's
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();
}
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);
}
}
Thank's