blob: 8da0f2798b003602d0ae05652aa09d51b0f4a080 (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// Copyright (C) 2022 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QGuiApplication>
#include <Qt3DCore/qentity.h>
#include <QtGui/QScreen>
#include <QtWidgets/QApplication>
#include <QtWidgets/QWidget>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QSlider>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QMainWindow>
#include <QQuickWidget>
int main(int argc, char **argv)
{
qputenv("QT3D_RENDERER", "opengl");
qputenv("QSG_RHI_BACKEND", "opengl");
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
QSurfaceFormat format(QSurfaceFormat::defaultFormat());
format.setVersion(3, 3);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setSamples(4);
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setSwapInterval(0); // 0 = vsync off
QSurfaceFormat::setDefaultFormat(format);
QApplication app(argc, argv);
QMainWindow mainWindow;
QQuickWidget *widget1 = new QQuickWidget();
widget1->resize(QSize(400, 400));
widget1->setResizeMode(QQuickWidget::SizeRootObjectToView);
widget1->setSource(QUrl("qrc:/main.qml"));
QQuickWidget *widget2 = new QQuickWidget();
widget2->resize(QSize(400, 400));
widget2->setResizeMode(QQuickWidget::SizeRootObjectToView);
widget2->setSource(QUrl("qrc:/main2.qml"));
auto centralWidget = new QWidget;
auto layout = new QHBoxLayout;
layout->addWidget(widget1);
layout->addWidget(widget2);
centralWidget->setLayout(layout);
mainWindow.setCentralWidget(centralWidget);
mainWindow.show();
return app.exec();
}
|