QObjectPicker Class

class Qt3DRender::QObjectPicker

The QObjectPicker class instantiates a component that can be used to interact with a QEntity by a process known as picking. More...

Header: #include <QObjectPicker>
qmake: QT += 3drender
Since: Qt 5.6
Instantiated By: ObjectPicker
Inherits: Qt3DCore::QComponent

This class was introduced in Qt 5.6.

Properties

Public Functions

bool containsMouse() const
bool isDragEnabled() const
bool isHoverEnabled() const
bool isPressed() const
int priority() const

Public Slots

void setDragEnabled(bool dragEnabled)
void setHoverEnabled(bool hoverEnabled)
void setPriority(int priority)

Signals

void containsMouseChanged(bool containsMouse)
void dragEnabledChanged(bool dragEnabled)
void hoverEnabledChanged(bool hoverEnabled)
void pressedChanged(bool pressed)
void priorityChanged(int priority)

Detailed Description

For every combination of viewport and camera, picking casts a ray through the scene to find entities who's bounding volume intersects the ray. The bounding volume is computed using the values in the attribute buffer specified by the boundingVolumePositionAttribute of the geometry.

The signals pressed(), released(), clicked(), moved(), entered(), and exited() are emitted when the bounding volume defined by the pickAttribute property intersects with a ray.

Most signals carry a QPickEvent instance. If QPickingSettings::pickMode() is set to QPickingSettings::TrianglePicking, the actual type of the pick parameter will be QPickTriangleEvent.

Pick queries are performed on mouse press and mouse release. If drag is enabled, queries also happen on each mouse move while any button is pressed. If hover is enabled, queries happen on every mouse move even if no button is pressed.

For generalised ray casting queries, see Qt3DRender::QRayCaster and Qt3DRender::QScreenRayCaster.

Note: Instances of this component shouldn't be shared, not respecting that condition will most likely result in undefined behavior.

Note: The camera far plane value affects picking and produces incorrect results due to floating-point precision if it is greater than ~100 000.

See also Qt3DRender::QPickingSettings, Qt3DRender::QGeometry, Qt3DRender::QAttribute, Qt3DRender::QPickEvent, Qt3DRender::QPickTriangleEvent, and Qt3DRender::QNoPicking.

Property Documentation

containsMouse : const bool

Specifies if the object picker currently contains the mouse

Access functions:

bool containsMouse() const

Notifier signal:

void containsMouseChanged(bool containsMouse)

dragEnabled : bool

Specifies if drag is enabled

Access functions:

bool isDragEnabled() const
void setDragEnabled(bool dragEnabled)

Notifier signal:

void dragEnabledChanged(bool dragEnabled)

hoverEnabled : bool

Specifies if hover is enabled

Access functions:

bool isHoverEnabled() const
void setHoverEnabled(bool hoverEnabled)

Notifier signal:

void hoverEnabledChanged(bool hoverEnabled)

pressed : const bool

Specifies if the object picker is currently pressed

Access functions:

bool isPressed() const

Notifier signal:

void pressedChanged(bool pressed)

priority : int

The priority to be used when filtering pick results by priority when QPickingSettings::pickResultMode is set to QPickingSettings::NearestPriorityPick.

Access functions:

int priority() const
void setPriority(int priority)

Notifier signal:

void priorityChanged(int priority)