QT Quick3D。 View3d不显示

发布于 2025-02-05 02:34:43 字数 1511 浏览 1 评论 0 原文

我需要将此C ++项目移植到Python
The original project uses Qt3DQuickWindow which doesn't exist in python so I'm using a QQuickView

class QuickWidget:
    def __init__(self):
        self.app = QApplication(sys.argv)
        format = QSurfaceFormat()
        if QOpenGLContext.openGLModuleType() == QOpenGLContext.LibGL:
            format.setVersion(3, 2)
            format.setProfile(QSurfaceFormat.CoreProfile)
        format.setDepthBufferSize(24)
        format.setStencilBufferSize(8)
        format.setSamples(4)

        self.controller = SceneController()
        self.controllerWidget = ControllerWidget(self.controller)
        self.controllerWidget.show()
        self.view = QQuickView()
        self.view.setFormat(format)
        self.view.setResizeMode(QQuickView.SizeRootObjectToView)
        self.view.rootContext().setContextProperty("_controller", self.controller)
        self.view.setSource(QUrl("main_quick.qml"))
        self.view.show()
        self.app.exec_()

I wrapped the main qml class

Item {
    id: mainview
    width: 1280
    height: 768
    visible: true
    View3D {
        anchors.fill: parent

        DefaultSceneEntity {
        /// code from the original project
        }
    }
}

我没有更改其他QML文件。

I need to port this C++ project to python https://github.com/KDAB/qt3d-examples/tree/master/blended-skinned-animation
The original project uses Qt3DQuickWindow which doesn't exist in python so I'm using a QQuickView

class QuickWidget:
    def __init__(self):
        self.app = QApplication(sys.argv)
        format = QSurfaceFormat()
        if QOpenGLContext.openGLModuleType() == QOpenGLContext.LibGL:
            format.setVersion(3, 2)
            format.setProfile(QSurfaceFormat.CoreProfile)
        format.setDepthBufferSize(24)
        format.setStencilBufferSize(8)
        format.setSamples(4)

        self.controller = SceneController()
        self.controllerWidget = ControllerWidget(self.controller)
        self.controllerWidget.show()
        self.view = QQuickView()
        self.view.setFormat(format)
        self.view.setResizeMode(QQuickView.SizeRootObjectToView)
        self.view.rootContext().setContextProperty("_controller", self.controller)
        self.view.setSource(QUrl("main_quick.qml"))
        self.view.show()
        self.app.exec_()

I wrapped the main qml class https://github.com/KDAB/qt3d-examples/blob/master/blended-skinned-animation/main.qml inside an Item and a View3D.

Item {
    id: mainview
    width: 1280
    height: 768
    visible: true
    View3D {
        anchors.fill: parent

        DefaultSceneEntity {
        /// code from the original project
        }
    }
}

I didn't change the other qml files.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文