我在ubuntu 18.04中使用qt 5.5,我需要显示3d模型(以obj格式),我使用qquickwidget和qml(Scene3D),它对于显示模型很好用,但是当应用程序退出时,它将崩溃。我从qtcreator控制台收到的以下错误消息如下:
QMutex::lock() 0x7ffff53b0725
QSemaphore::acquire(int) 0x7ffff53b23f4
Qt3D::QAspectManager::quit() 0x7fffc77c03bd
Qt3D::QAspectEngine::shutdown() 0x7fffc77be54a
Qt3D::QAspectEngine::~QAspectEngine() 0x7fffc77be94e
Qt3D::QAspectEngine::~QAspectEngine() 0x7fffc77be9d9
?? 0x7fffc8036c27
QMetaObject::activate(QObject *, int, int, void * *) 0x7ffff55d3cfa
QObject::destroyed(QObject *) 0x7ffff55d4a6f
QObject::~QObject() 0x7ffff55dcdab
QQuickWindow::~QQuickWindow() 0x7ffff3d43931
QQuickWindow::~QQuickWindow() 0x7ffff3d43999
?? 0x7ffff76bbb8a
?? 0x7ffff76bbc99
QObject::~QObject() 0x7ffff55dcb6b
QWidget::~QWidget() 0x7ffff6fc600b
QQuickWidget::~QQuickWidget() 0x7ffff76bb119
QObjectPrivate::deleteChildren() 0x7ffff55d2bdc
QWidget::~QWidget() 0x7ffff6fc5f8b
似乎是因为QQuickWindow析构函数被调用了两次。我曾尝试删除qml中与3d相关的核心,只需绘制一个简单的2d矩形,它就不会崩溃,有人帮助我解决此问题,非常感谢。贝娄是我的qml文件; (1)main.qml
import QtQuick 2.0
import QtQuick.Scene3D 2.0
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2
import Qt3D 2.0
Item {
id: main
Camera {
id: camera
}
Entity {
components: [
ShadowMapFrameGraph {
id: framegraph
viewCamera: camera
lightCamera: light.lightCamera
}
]
}
Light {
id: light
}
AdsEffect {
id: shadowMapEffect
shadowTexture: framegraph.shadowTexture
light: light
}
Scene3D {
id: scene3D
anchors.fill: parent
anchors.verticalCenter: parent.verticalCenter
focus: true
aspects: "input"
obj_model{
id: model
}
}
}
(2)obj_model.qml
import Qt3D 2.0
import Qt3D.Renderer 2.0
import QtQuick 2.1 as QQ2
Entity {
id: root
property Material material
Camera {
id: camera
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 40
aspectRatio: 4/3
nearPlane : 0.1
farPlane : 3000.0
position: Qt.vector3d( 0.0, -1000, 300.0 )
upVector: Qt.vector3d( 0.0, 0.0, 1.0 )
viewCenter: Qt.vector3d( 0.0, 0.0, 300.0 )
}
Configuration {
controlledCamera: camera
}
components: [
FrameGraph {
activeFrameGraph: ForwardRenderer {
camera: camera
clearColor: "white"
}
}
]
PhongMaterial {
id: material
ambient: Qt.rgba( 0.8, 0.8, 0.8, 1.0 )
diffuse: Qt.rgba( 0.1, 0.1, 0.1, 0.5 )
shininess: 50 //shining.value
}
Transform {
id: logoTransform
}
Mesh {
id: logoMesh
source: "../res/model.obj"
}
Entity {
id: logoEntity
components: [ logoMesh, material, logoTransform ]
}
}
答案 0 :(得分:0)
这是qt 5.5的错误,需要更新qt版本。