Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt3D ObjectPicker is shifted if a QtQuick Object is to the left of the Scene3D
Forum Update on Monday, May 27th 2025

Qt3D ObjectPicker is shifted if a QtQuick Object is to the left of the Scene3D

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
bug
2 Posts 1 Posters 323 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    ghing
    wrote on 22 Feb 2023, 22:46 last edited by ghing
    #1

    I am using Qt 6.4.2 and a Scene3D in an QApplicationWindow. In the Scene3D I have an object (e.g., a Torus Mesh). I use the ObjectPicker to interact with the mesh. If there is a QtQuick Object (e.g., Rectangle) to the left of the Scene3D, the events pressed, clicked, released get triggered if the mouse is off from the mesh by the width of that element, i.e., if the mouse is to the left of the mesh by the width of the Rectangle Object. The moved event is correctly triggered, i.e., when the mouse is on top of the mesh. Is this a bug or am I doing something wrong here?

    Screenshot 2023-02-22 234027.png

    // main.qml
    
    import QtQuick
    import QtQuick.Controls
    import Qt3D.Core 2.4
    import Qt3D.Render 2.4
    import Qt3D.Input 2.4
    import Qt3D.Extras 2.4
    import QtQuick.Scene3D 2.4
    
    ApplicationWindow {
        id: window
        width: 640
        height: 480
        visible: true
    
        Page {
            id: viewerPage
            width: window.width
            height: window.height
            title: "title"
    
            Row {
                Rectangle {
                    width: window.width/4.0
                    height:window.height
                    color:"blue"
                }
    
                Rectangle  {
                    id:sceneRect
                    width: window.width/4.0*3.0
                    height:window.height
                    color:"black"
    
                    Scene3D {
                        id: scene3d
                        anchors.fill: parent
                        focus: true
                        aspects: ["input", "logic"]
                        cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
                        MyEntity {
                            id: rootEntity
                        }
                    }
                }
            }
        }
    }
    
    // MyEntity.qml
    import Qt3D.Core 2.4
    import Qt3D.Render 2.4
    import Qt3D.Input 2.4
    import Qt3D.Extras 2.4
    
    import QtQuick
    
    
    Entity {
        id: sceneRoot
    
        Camera {
            id: camera
            projectionType: CameraLens.PerspectiveProjection
            fieldOfView: 45
            nearPlane : 0.1
            farPlane : 1000.0
            position: Qt.vector3d( 0.0, 0.0, 40.0 )
            upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
            viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
        }
    
        OrbitCameraController { camera: camera }
        components: [
            RenderSettings {
                id: renderSettings
                activeFrameGraph: ForwardRenderer {
                    camera: camera
                    clearColor: "red"
                }
                pickingSettings.pickMethod: PickingSettings.TrianglePicking
            },
            InputSettings { }
    
    
        ]
    
        PhongMaterial {
            id: material
            diffuse: "yellow"
        }
    
        TorusMesh {
            id: torusMesh
            radius: 5
            minorRadius: 1
            rings: 100
            slices: 20
        }
    
        Transform {
            id: torusTransform
            scale3D: Qt.vector3d(1.5, 1, 0.5)
            rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
        }
        ObjectPicker {
            id:picker
    
            hoverEnabled: true
            dragEnabled:true
            onClicked: console.log("onClicked")
            onMoved: console.log("onMoved")
            onReleased: console.log("onReleased")
            onPressed: console.log("onPressed")
        }
        Entity {
            id: torusEntity
            components: [ torusMesh, material, torusTransform,picker ]
        }
    
    
        Entity {
            id: lightEntity
            components: [ pointLight, pointLightTransform]
            PointLight {
                id: pointLight
            }
            Transform {
                id:pointLightTransform
                translation: camera.position
            }
        }
    }
    
    // main.cpp
    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    
    int main(int argc, char *argv[])
    {
    #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    #endif
    
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        const QUrl url(QStringLiteral("qrc:/main.qml"));
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                         &app, [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
        engine.load(url);
    
        return app.exec();
    }
    1 Reply Last reply
    0
    • G Offline
      G Offline
      ghing
      wrote on 23 Feb 2023, 12:39 last edited by
      #2

      I realized that the erroneous behaviour is caused by the Page Object. The same happens if Page is replaced with Pane. However it works if one uses Control or Item instead. I hope this helps if someone encounters the same issue. Maybe it will be fixed in future Qt versions.

      1 Reply Last reply
      0

      2/2

      23 Feb 2023, 12:39

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved