Crash when loading Studio3D scene
Solved
QML and Qt Quick
-
Hello,
I'm trying to load 3D studio scene example but it crash after loading scene and open the window.
environment:
QT 5.11.0 MSVC 2017 , Qt Studio 2.0, Windows 10, GTX745 OpenGL 4
What is wrong with my code?
QT += quick qml 3dstudioruntime2 CONFIG += c++11 # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp RESOURCES += qml.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target
main.cpp
#include <QtWidgets/QApplication> // for MessageDialog #include <QtQuick/QQuickView> #include <q3dsruntimeglobal.h> int main(int argc, char *argv[]) { qputenv("QSG_INFO", "1"); QApplication app(argc, argv); // Use the ideal format (i.e. OpenGL version and profile) recommended by // the Qt 3D Studio runtime. Without this the format set on the QQuickView // would be used instead. QSurfaceFormat::setDefaultFormat(Q3DS::surfaceFormat()); QQuickView viewer; viewer.setSource(QUrl("qrc:/main.qml")); viewer.setTitle(QStringLiteral("Qt 3D Studio Example")); viewer.setResizeMode(QQuickView::SizeRootObjectToView); viewer.resize(1280, 720); viewer.show(); return app.exec(); }
main.qml
import QtQuick 2.0 import QtStudio3D 2.0 import QtQuick.Window 2.3 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import Qt.labs.platform 1.0 Rectangle { id: root color: "lightGray" MessageDialog { id: errorDialog } Studio3D { id: s3d focus: true anchors.margins: 60 anchors.fill: parent property string textValue: "hello world" Presentation { id: s3dpres source: "qrc:/presentation/SampleProject.uip" } } }
qml.qrc
<RCC> <qresource prefix="/"> <file>main.qml</file> <file>presentation/effects/VignetteEffect.effect</file> <file>presentation/fonts/TitilliumWeb-Regular.ttf</file> <file>presentation/maps/gradient_lines_001.png</file> <file>presentation/maps/Icon_TurnLeft_ON.png</file> <file>presentation/maps/kmh260.png</file> <file>presentation/maps/OpenfootageNET_garage-512.hdr</file> <file>presentation/maps/road.png</file> <file>presentation/maps/Rpm7.png</file> <file>presentation/models/needle_2/meshes/qt_gauge_needles_2.mesh</file> <file>presentation/models/needle_2/needle_2.import</file> <file>presentation/models/Ring_2/meshes/qt_gauge_ring_2.mesh</file> <file>presentation/models/Ring_2/Ring_2.import</file> <file>presentation/models/roundbg_1/maps/gradient.png</file> <file>presentation/models/roundbg_1/meshes/qt_gauge_background_round_1.mesh</file> <file>presentation/models/roundbg_1/roundbg_1.import</file> <file>presentation/models/Sportscar_15k/maps/c_tex.jpg</file> <file>presentation/models/Sportscar_15k/meshes/backWheels.mesh</file> <file>presentation/models/Sportscar_15k/meshes/BodyBack.mesh</file> <file>presentation/models/Sportscar_15k/meshes/BodyFront.mesh</file> <file>presentation/models/Sportscar_15k/meshes/frontWheels.mesh</file> <file>presentation/models/Sportscar_15k/Sportscar_15k.import</file> <file>presentation/models/tickmark_260/meshes/qt_gauge_tickmarks_260.mesh</file> <file>presentation/models/tickmark_260/tickmark_260.import</file> <file>presentation/models/tickmark_8_small/meshes/qt_gauge_tickmarks_8_small.mesh</file> <file>presentation/models/tickmark_8_small/tickmark_8_small.import</file> <file>presentation/scripts/dateAndTime.qml</file> <file>presentation/scripts/Map.jpg</file> <file>presentation/scripts/Navigation.qml</file> <file>presentation/scripts/Navigation.qmlc</file> <file>presentation/SampleProject.uia</file> <file>presentation/SampleProject.uip</file> <file>main.cpp</file> </qresource> </RCC>
thank you for your help