Obsolete Members for QMouseEvent

以下成员源于类 QMouseEvent 被弃用。 提供它们是为使旧源代码能继续工作。强烈建议不要在新代码中使用它们。

公共函数

(deprecated (6.4)) QMouseEvent (QEvent::Type type , const QPointF & localPos , Qt::MouseButton button , Qt::MouseButtons buttons , Qt::KeyboardModifiers modifiers , const QPointingDevice * device = QPointingDevice::primaryPointingDevice())
(deprecated (6.0)) QPoint globalPos () const
(deprecated (6.0)) int globalX () const
(deprecated (6.0)) int globalY () const
(deprecated (6.0)) QPointF localPos () const
(deprecated (6.0)) QPoint pos () const
(deprecated (6.0)) QPointF screenPos () const
(deprecated (6.0)) Qt::MouseEventSource source () const
(deprecated (6.0)) QPointF windowPos () const
(deprecated (6.0)) int x () const
(deprecated (6.0)) int y () const

成员函数文档编制

QMouseEvent:: QMouseEvent ( QEvent::Type type , const QPointF & localPos , Qt::MouseButton button , Qt::MouseButtons buttons , Qt::KeyboardModifiers modifiers , const QPointingDevice * device = QPointingDevice::primaryPointingDevice())

This function is deprecated since 6.4. We strongly advise against using it in new code.

Use another constructor instead (global position is required).

构造鼠标事件对象源自 device .

The type 参数必须是某一 QEvent::MouseButtonPress , QEvent::MouseButtonRelease , QEvent::MouseButtonDblClick ,或 QEvent::MouseMove .

The localPos 是鼠标光标相对于接收 Widget 或项的位置。窗口位置会被设为相同值如 localPosbutton 导致给定值事件来自 Qt::MouseButton 枚举。若事件 type is MouseMove ,此事件的相应按钮为 Qt::NoButton 。事件发生时的鼠标和键盘状态的指定是通过 buttons and modifiers .

The globalPosition () 被初始化为 QCursor::pos (),可能不合适。使用其它构造函数以明确指定全局位置。

QPoint QMouseEvent:: globalPos () const

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 globalPosition ().toPoint() instead.

返回鼠标光标的全局位置 当事件发生时 。这对异步窗口系统 (像 X11) 很重要。每当围绕响应鼠标事件移动 Widget 时,globalPos() 会非常不同于当前指针位置 QCursor::pos (),和来自 QWidget::mapToGlobal ( pos ()).

另请参阅 globalX () 和 globalY ().

int QMouseEvent:: globalX () const

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 globalPosition (). x () 代替。

返回事件发生时的鼠标光标全局 X 位置。

另请参阅 globalY () 和 globalPos ().

int QMouseEvent:: globalY () const

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 globalPosition (). y () 代替。

返回事件发生时的鼠标光标全局 Y 位置。

另请参阅 globalX () 和 globalPos ().

QPointF QMouseEvent:: localPos () const

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 position () 代替。

将鼠标光标位置返回作为 QPointF ,相对于接收事件的 Widget 或项。

若因鼠标事件导致 Widget 移动,使用屏幕位置返回通过 screenPos () 以避免晃动。

另请参阅 x (), y (), windowPos (),和 screenPos ().

QPoint QMouseEvent:: pos () const

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 position () 代替。

返回鼠标光标的位置,相对于接收事件的 Widget。

若因鼠标事件导致 Widget 移动,使用全局位置返回通过 globalPos () 以避免晃动。

另请参阅 x (), y (),和 globalPos ().

QPointF QMouseEvent:: screenPos () const

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 globalPosition () 代替。

将鼠标光标位置返回作为 QPointF ,相对于接收事件的屏幕。

另请参阅 x (), y (), pos (), localPos (),和 windowPos ().

Qt::MouseEventSource QMouseEvent:: source () const

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 pointingDevice () 代替。

返回鼠标事件来源的有关信息。

The mouse event source can be used to distinguish between genuine and artificial mouse events. The latter are events that are synthesized from touch events by the operating system or Qt itself. This enum tells you from where it was synthesized; but often it's more useful to know from which device it was synthesized, so try to use pointingDevice () 代替。

注意: 很多平台不提供这种信息。在这种平台 Qt::MouseEventNotSynthesized 始终被返回。

注意: In Qt 5-based code, source() was often used to attempt to distinguish mouse events from an actual mouse vs. those that were synthesized because some legacy QQuickItem or QWidget subclass did not react to a QTouchEvent . However, you could not tell whether it was synthesized from a QTouchEvent QTabletEvent , and other information was lost. pointingDevice () tells you the specific device that it came from, so you might check pointingDevice()->type() or pointingDevice()->capabilities() to decide how to react to this event. But it's even better to react to the original event rather than handling only mouse events.

另请参阅 Qt::MouseEventSource and QGraphicsSceneMouseEvent::source ().

QPointF QMouseEvent:: windowPos () const

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 scenePosition () 代替。

将鼠标光标位置返回作为 QPointF ,相对接收事件的窗口。

若因鼠标事件导致 Widget 移动,使用全局位置返回通过 globalPos () 以避免晃动。

另请参阅 x (), y (), pos (), localPos (),和 screenPos ().

int QMouseEvent:: x () const

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 position ().x() instead.

返回相对于接收事件 Widget 的鼠标光标 X 位置。

另请参阅 y () 和 pos ().

int QMouseEvent:: y () const

This function is deprecated since 6.0. We strongly advise against using it in new code.

使用 position ().y() instead.

返回相对于接收事件 Widget 的鼠标光标 Y 位置。

另请参阅 x () 和 pos ().