aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/quickwidgets/qquickwidgetversuswindow_opengl/main.cpp
blob: 8c9577557703fdd3a40b7dfc7152751af5766804 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include <QApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>

#include "mainwindow.h"

int main(int argc, char **argv)
{
    qputenv("QML_BAD_GUI_RENDER_LOOP", "1"); // QTBUG-39507

    QApplication app(argc, argv);

    // this example and QQuickWidget are only functional when rendering with OpenGL
    QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);

    QCoreApplication::setApplicationName("Qt QQuickView/QQuickWidget Comparison Example");
    QCoreApplication::setOrganizationName("QtProject");
    QCoreApplication::setApplicationVersion(QT_VERSION_STR);
    QCommandLineParser parser;
    parser.setApplicationDescription(QCoreApplication::applicationName());
    parser.addHelpOption();
    parser.addVersionOption();
    QCommandLineOption noRenderAlphaOption("no-render-alpha", "Do not render Alpha");
    parser.addOption(noRenderAlphaOption);
    QCommandLineOption transparentOption("transparent", "Transparent window");
    parser.addOption(transparentOption);

    parser.process(app);

    const bool transparency = parser.isSet(transparentOption);
    MainWindow widgetWindow(transparency, parser.isSet(noRenderAlphaOption));
    if (transparency) {
        widgetWindow.setAttribute(Qt::WA_TranslucentBackground);
        widgetWindow.setAttribute(Qt::WA_NoSystemBackground, false);
    }

    widgetWindow.resize(1024, 768);
    widgetWindow.show();

    return app.exec();
}