赞
踩
Returns the global position of the mouse cursor at the time of the event. This is important on asynchronous window systems like X11. Whenever you move your widgets around in response to mouse events, globalPos() may differ a lot from the current pointer position QCursor::pos(), and from QWidget::mapToGlobal(pos()).
See also globalX() and globalY().
Returns the global x position of the mouse cursor at the time of the event.
See also globalY() and globalPos().
Returns the global y position of the mouse cursor at the time of the event.
See also globalX() and globalPos().
Returns the position of the mouse cursor as a QPointF, relative to the widget or item that received the event.
If you move the widget as a result of the mouse event, use the screen position returned by screenPos() to avoid a shaking motion.
This function was introduced in Qt 5.0.
See also x(), y(), windowPos(), and screenPos().
Returns the position of the mouse cursor, relative to the widget that received the event.
If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.
See also x(), y(), and globalPos().
Returns the position of the mouse cursor as a QPointF, relative to the screen that received the event.
This function was introduced in Qt 5.0.
See also x(), y(), pos(), localPos(), and windowPos().
Returns information about the mouse event source.
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.
Note: Many platforms provide no such information. On such platforms Qt::MouseEventNotSynthesized is returned always.
This function was introduced in Qt 5.3.
See also Qt::MouseEventSource and QGraphicsSceneMouseEvent::source().
Returns the position of the mouse cursor as a QPointF, relative to the window that received the event.
If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.
This function was introduced in Qt 5.0.
See also x(), y(), pos(), localPos(), and screenPos().
Returns the x position of the mouse cursor, relative to the widget that received the event.
Returns the y position of the mouse cursor, relative to the widget that received the event.
int | globalX() const |
int | globalY() const |
返回鼠标的全局位置
屏幕左上角为0 0
x()
y()
相对于接受消息窗口的位置
和globalPos一样。一个是Int 一个是float
和local一样。一个是Int 一个是float
globalPos(),给出的坐标信息是相对于桌面的,即以桌面左上角为原点。
pos(),是相对于窗口的,以窗口左上角为原点(去除边框)。即pos()给出的是一个相对位置坐标。而globalPos(),给出的是一个绝对坐标。
FROM: http://blog.163.com/qimo601@126/blog/static/158220932014423114030117/
1、QPoint QMouseEvent::pos()
这个只是返回相对这个widget(重载了QMouseEvent的widget)的位置。
const Returns the position of the mouse cursor, relative to the widget that received the event. If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.
2、QPoint QMouseEvent::globalPos()
窗口坐标,这个是返回鼠标的全局坐标
const Returns the global position of the mouse cursor at the time of the event. This is important on asynchronous window systems like X11. Whenever you move your widgets around in response to mouse events,globalPos() may differ a lot from the current pointer position QCursor::pos(), and from QWidget::mapToGlobal(pos()).
3、QPoint QCursor::pos() [static]
返回相对显示器的全局坐标
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates. You can call QWidget::mapFromGlobal() to translate it to widget coordinates. Note: The position is queried from the windowing system. If mouse events are generated via other means (e.g., via QWindowSystemInterface in a unit test), those fake mouse moves will not be reflected in the returned value. Note: On platforms where there is no windowing system or cursors are not available, the returned position is based on the mouse move events generated via QWindowSystemInterface.
4、QWidget::pos() : QPoint
这个属性获得的是当前目前控件在父窗口中的位置,
This property holds the position of the widget within its parent widget.
If the widget is a window, the position is that of the widget on the desktop, including its frame.
When changing the position, the widget, if visible, receives a move event (moveEvent()) immediately. If the widget is not currently visible, it is guaranteed to receive an event before it is shown.
By default, this property contains a position that refers to the origin.
Warning: Calling move() or setGeometry() inside moveEvent() can lead to infinite recursion.
See the Window Geometry documentation for an overview of geometry issues with windows.
5、const QPointF & QMouseEvent::screenPos() const
Returns the position of the mouse cursor as a QPointF, relative to the screen that received the event.
和QPoint QMouseEvent::globalPos() 值相同,但是类型更高精度的QPointF
This function was introduced in Qt 5.0.
本博客仅供学习使用,r
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。