| 1 | // Copyright (C) 2022 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include <QGuiApplication> |
| 5 | |
| 6 | #include <Qt3DCore/qentity.h> |
| 7 | #include <QtGui/QScreen> |
| 8 | |
| 9 | #include <QtWidgets/QApplication> |
| 10 | #include <QtWidgets/QWidget> |
| 11 | #include <QtWidgets/QHBoxLayout> |
| 12 | #include <QtWidgets/QSlider> |
| 13 | #include <QtWidgets/QLabel> |
| 14 | #include <QtWidgets/QPushButton> |
| 15 | |
| 16 | #include <QMainWindow> |
| 17 | #include <QQuickWidget> |
| 18 | |
| 19 | int main(int argc, char **argv) |
| 20 | { |
| 21 | qputenv("QT3D_RENDERER", "opengl"); |
| 22 | qputenv("QSG_RHI_BACKEND", "opengl"); |
| 23 | |
| 24 | QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); |
| 25 | QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL); |
| 26 | |
| 27 | QSurfaceFormat format(QSurfaceFormat::defaultFormat()); |
| 28 | format.setVersion(3, 3); |
| 29 | format.setProfile(QSurfaceFormat::CoreProfile); |
| 30 | format.setSamples(4); |
| 31 | format.setDepthBufferSize(24); |
| 32 | format.setStencilBufferSize(8); |
| 33 | format.setSwapInterval(0); // 0 = vsync off |
| 34 | QSurfaceFormat::setDefaultFormat(format); |
| 35 | |
| 36 | QApplication app(argc, argv); |
| 37 | |
| 38 | QMainWindow mainWindow; |
| 39 | |
| 40 | QQuickWidget *widget1 = new QQuickWidget(); |
| 41 | widget1->resize(QSize(400, 400)); |
| 42 | widget1->setResizeMode(QQuickWidget::SizeRootObjectToView); |
| 43 | widget1->setSource(QUrl("qrc:/main.qml")); |
| 44 | |
| 45 | QQuickWidget *widget2 = new QQuickWidget(); |
| 46 | widget2->resize(QSize(400, 400)); |
| 47 | widget2->setResizeMode(QQuickWidget::SizeRootObjectToView); |
| 48 | widget2->setSource(QUrl("qrc:/main2.qml")); |
| 49 | |
| 50 | auto centralWidget = new QWidget; |
| 51 | auto layout = new QHBoxLayout; |
| 52 | layout->addWidget(widget1); |
| 53 | layout->addWidget(widget2); |
| 54 | centralWidget->setLayout(layout); |
| 55 | mainWindow.setCentralWidget(centralWidget); |
| 56 | |
| 57 | mainWindow.show(); |
| 58 | |
| 59 | return app.exec(); |
| 60 | } |