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
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
<
QtGui
>
5
#
include
<
QtUiTools
>
6
7
#
include
"mywidget.h"
8
9
using
namespace
Qt::StringLiterals;
10
11
//! [0]
12
QWidget
*
loadCustomWidget
(
const
QString &className, QWidget *parent)
13
{
14
QUiLoader loader;
15
QStringList availableWidgets = loader.availableWidgets();
16
17
if
(!availableWidgets.contains(className)) {
18
qWarning() <<
"Cannot create widget"
<< className;
19
return
nullptr
;
20
}
21
22
return
loader.createWidget(className, parent);
23
}
24
//! [0]
25
26
int
main
(
int
argc,
char
*argv[])
27
{
28
QApplication app(argc, argv);
29
MyWidget
widget;
30
widget.show();
31
32
if
(QWidget *customWidget = loadCustomWidget(
"AnalogClock"_L1
,
nullptr
))
33
customWidget->show();
34
return
app.exec();
35
}
MyWidget
[24]
Definition
src_corelib_kernel_qobject.cpp:264
loadCustomWidget
QWidget * loadCustomWidget(const QString &className, QWidget *parent)
[0]
Definition
main.cpp:12
main
int main(int argc, char *argv[])
[ctor_close]
Definition
src_corelib_animation_qpropertyanimation.cpp:100
qttools
src
uitools
doc
snippets
quiloader
main.cpp
Generated on
for Qt by
1.14.0