Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QtWidgets>
5
6int main(int argc, char *argv[])
7{
8 QApplication app(argc, argv);
9 QObject *parent = &app;
10
11 QStringList numbers;
12 numbers << "One" << "Two" << "Three" << "Four" << "Five";
13
14 QAbstractItemModel *stringListModel = new QStringListModel(numbers, parent);
15
17 QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(parent);
18 filterModel->setSourceModel(stringListModel);
20
21 QWidget *window = new QWidget;
22
24 QListView *filteredView = new QListView;
25 filteredView->setModel(filterModel);
27 filteredView->setWindowTitle("Filtered view onto a string list model");
28
29 QLineEdit *patternEditor = new QLineEdit;
32
34 layout->addWidget(filteredView);
35 layout->addWidget(patternEditor);
36
37 window->show();
38 return app.exec();
39}
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
The QApplication class manages the GUI application's control flow and main settings.
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
The QLineEdit widget is a one-line text editor.
Definition qlineedit.h:28
void textChanged(const QString &)
This signal is emitted whenever the text changes.
The QListView class provides a list or icon view onto a model.
Definition qlistview.h:17
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
The QSortFilterProxyModel class provides support for sorting and filtering data passed between anothe...
void setFilterWildcard(const QString &pattern)
Sets the wildcard expression used to filter the contents of the source model to the given pattern.
\inmodule QtCore
\inmodule QtCore
The QVBoxLayout class lines up widgets vertically.
Definition qboxlayout.h:91
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
int main()
[0]
QVBoxLayout * layout
QApplication app(argc, argv)
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]