首页 > 解决方案 > QML:使用 NodeInstantiator 实例化时未触发 Scene2D 单击事件

问题描述

我正在创建一个 3D QtWayland 合成器,当将 ShellSurfaceItems 放在 Qt3D 平面上时,我使用 NodeInstantiator。这样做会注册除我的 Scene2D 上的实体之外的所有属性(我用来在 3D 平面上显示 2D ShellSurfaceItem)

我已经尝试了从加载组件时设置实体属性到手动实例化我的自定义面板组件(所有 QML)的所有方法。实体根本不链接到 Scene2D 中的事件处理程序

节点实例化器:

NodeInstantiator {
        model: shellSurfaces

        Panel {
            id:panel
            shellSurf: modelData
            listIndex: index
        }
    }

面板.qml:

Entity {
    ...
    id:panel
    components: [panelTransform, planeMesh, material, panelPicker]
    ...
    Scene2D {
        id: waylandScene
        output: RenderTargetOutput { ... }
        mouseEnabled: true
        entities: [parent]

        ShellSurfaceItem { ... }
    }
    ...
}

该程序应该在创建面板时将 Scene2D 单击处理程序链接到 Scene2D 类中的 ObjectPicker。然而,这并没有完成,因为 Scene2D 在entities属性更改时从不执行其内部方法。

标签: qtqmlqt3dqtwayland

解决方案


推荐阅读