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) 2017 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
#include <QQuickView>
4
#include <QQmlContext>
5
6
#include <QApplication>
7
#include <QFileSystemModel>
8
10
int
main
(
int
argc,
char
** argv)
11
{
12
QApplication
app
(argc, argv);
13
14
QQuickView
view
;
15
16
QFileSystemModel
model
;
17
view
.
rootContext
()->
setContextProperty
(
"fileSystemModel"
, &
model
);
18
19
view
.
setSource
(
QUrl::fromLocalFile
(
"view.qml"
));
20
view
.
show
();
21
22
return
app
.
exec
();
23
}
25
QApplication
The QApplication class manages the GUI application's control flow and main settings.
Definition
qapplication.h:32
QApplication::exec
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
Definition
qapplication.cpp:2560
QFileSystemModel
The QFileSystemModel class provides a data model for the local filesystem.
Definition
qfilesystemmodel.h:22
QQmlContext::setContextProperty
void setContextProperty(const QString &, QObject *)
Set the value of the name property on this context.
Definition
qqmlcontext.cpp:261
QQuickView
The QQuickView class provides a window for displaying a Qt Quick user interface.
Definition
qquickview.h:20
QQuickView::rootContext
QQmlContext * rootContext() const
This function returns the root of the context hierarchy.
Definition
qquickview.cpp:334
QQuickView::setSource
void setSource(const QUrl &)
Sets the source to the url, loads the QML component and instantiates it.
Definition
qquickview.cpp:234
QUrl::fromLocalFile
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition
qurl.cpp:3368
QWindow::show
void show()
Shows the window.
Definition
qwindow.cpp:2254
main
int main()
[0]
Definition
doc_src_objecttrees.cpp:5
model
QSqlQueryModel * model
[16]
Definition
sqldatabase_snippet.cpp:5
app
QApplication app(argc, argv)
[0]
view
QQuickView * view
[0]
Definition
src_plugins_platforms_qnx_qqnxwindow.cpp:5
qtdeclarative
src
qmlmodels
doc
snippets
delegatemodel
delegatemodel_rootindex
main.cpp
Generated by
1.10.0