My QObjectPicker won't behave



  • Someone please help me! I am displaying objects in a Qt3DWindow and I'm trying to select them with QObjectPicker. I create the ObjectPicker as follows:

    Qt3DRender::QObjectPicker *MeshGraphics::createObjectPicker()
    {
        Qt3DRender::QObjectPicker *picker = new Qt3DRender::QObjectPicker();
    
        if(QObject::connect(picker, SIGNAL(pressed(Qt3DRender::QPickEvent*)), 
                    this, SLOT(pickMesh(Qt3DRender::QPickEvent*))))
        {
            qDebug() << "signal successfully connected";
    
            return picker;
        }
    
        else
        {
            qDebug() << "connect() failed";
    
            return nullptr;
        }
    }
    

    and I add it to my entity like this:

    entity->addComponent(createObjectPicker());
    

    When I have my renderSettings as:

    Qt3DRender::QPickingSettings *settings = m_window->renderSettings()->pickingSettings();
    
    settings->setFaceOrientationPickingMode(Qt3DRender::QPickingSettings::FrontAndBackFace);
    
    settings->setPickMethod(Qt3DRender::QPickingSettings::TrianglePicking);
            
    settings->setPickResultMode(Qt3DRender::QPickingSettings::NearestPick);
    

    my "pickMesh" slot is never called, and the application outputs "signal successfully connected".
    If I turn off TriangePicking in my settings:

    Qt3DRender::QPickingSettings *settings = m_window->renderSettings()->pickingSettings();
            
    settings->setFaceOrientationPickingMode(Qt3DRender::QPickingSettings::FrontAndBackFace);
            
    //settings->setPickMethod(Qt3DRender::QPickingSettings::TrianglePicking);
            
    settings->setPickResultMode(Qt3DRender::QPickingSettings::NearestPick);
    

    Then my slot is called when I click next to my cube mesh without actually clicking on it. There are no error messages or compiler warnings. This is a serious issue, it needs to only call the slot if I click on the viewable surface. Someone please help me! Thank you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.