Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_qmltest_qquicktest.cpp
Go to the documentation of this file.
1
// Copyright (C) 2020 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
//! [2]
5
// src_qmltest_qquicktest.cpp
6
#
include
<
QtQuickTest
>
7
#
include
<
QQmlEngine
>
8
#
include
<
QQmlContext
>
9
#
include
<
QGuiApplication
>
10
11
class
Setup
:
public
QObject
12
{
13
Q_OBJECT
14
15
public
:
16
Setup
() {}
17
18
public
slots
:
19
void
applicationAvailable
()
20
{
21
// Initialization that only requires the QGuiApplication object to be available
22
}
23
24
void
qmlEngineAvailable
(
QQmlEngine
*
engine
)
25
{
26
// Initialization requiring the QQmlEngine to be constructed
27
engine
->
rootContext
()->
setContextProperty
(
"myContextProperty"
,
QVariant
(
true
));
28
}
29
30
void
cleanupTestCase
()
31
{
32
// Implement custom resource cleanup
33
}
34
};
35
36
QUICK_TEST_MAIN_WITH_SETUP(mytest, Setup)
37
38
#
include
"src_qmltest_qquicktest.moc"
39
//! [2]
Setup
[2]
Definition
src_qmltest_qquicktest.cpp:12
qtdeclarative
src
qmltest
doc
snippets
src_qmltest_qquicktest.cpp
Generated on
for Qt by
1.14.0