-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
44 lines (36 loc) · 1.13 KB
/
mainwindow.cpp
File metadata and controls
44 lines (36 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "mainwindow.h"
#include "narrowablefilterproxymodel.h"
#include "ui_mainwindow.h"
#include <QSortFilterProxyModel>
#include <QStringListModel>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QStringList list;
for (int ii = 0; ii < 30000; ++ii) {
list.append(QString::number(qrand()));
}
QStringListModel *model = new QStringListModel(this);
model->setStringList(list);
NarrowableFilterProxyModel *filter = new NarrowableFilterProxyModel(this);
ui->listView->setModel(filter);
// Test that we reapply the filters on source changed by applying
// them **before** setting the source model.
ui->lineEdit->setText("1");
ui->lineEdit->setText("11");
ui->lineEdit->setText("111");
filter->setSourceModel(model);
filter->printRowCounts();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_lineEdit_textChanged(const QString &text)
{
NarrowableFilterProxyModel *filter = (NarrowableFilterProxyModel*) ui->listView->model();
filter->setFilterFixedString(text);
filter->printRowCounts();
}