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
9using namespace Qt::StringLiterals;
10
11//! [0]
12QWidget *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
26int 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}
QWidget * loadCustomWidget(const QString &className, QWidget *parent)
[0]
Definition main.cpp:12
int main(int argc, char *argv[])
[ctor_close]