Qt获取控件位置坐标详解
来源:互联网 发布:如何联系淘宝投诉店家 编辑:程序博客网 时间:2024/06/07 10:26
1. QPoint QMouseEvent::pos()
这个只是返回相对这个widget(重载了QMouseEvent的widget)的位置。
const Returns the position of the mouse cursor, relative to the widgetthat 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 theevent. This is important on asynchronous window systems like X11. Whenever youmove your widgets around in response to mouse events, globalPos() may differ alot from the current pointer position QCursor::pos(), and fromQWidget::mapToGlobal(pos()).
3. QPoint QCursor::pos() [static]
返回相对显示器的全局坐标
Returns the position of the cursor (hot spot) of the primary screen inglobal screen coordinates. You can call QWidget::mapFromGlobal() to translateit to widget coordinates. Note: The position is queried from the windowingsystem. If mouse events are generated via other means (e.g., viaQWindowSystemInterface in a unit test), those fake mouse moves will not bereflected in the returned value. Note: On platforms where there is no windowingsystem or cursors are not available, the returned position is based on the mousemove events generated via QWindowSystemInterface.
4. QPoint QWidget::mapToGlobal(const QPoint & pos) const
将窗口坐标转换成显示器坐标
Translates the widget coordinate pos to global screen coordinates. Forexample, mapToGlobal(QPoint(0,0)) would give the global coordinates of thetop-left pixel of the widget. See also mapFromGlobal(), mapTo(), andmapToParent().
5. QPoint QWidget::mapFromGlobal(const QPoint & pos) const
将显示器坐标转换成窗口坐标
Translates the global screen coordinate pos to widget coordinates.
6. QPoint QWidget::mapToParent(const QPoint & pos) const
将窗口坐标获得的pos转换成父类widget的坐标
Translates the widget coordinate pos to acoordinate in the parent widget.
7. QPoint QWidget::mapFromParent(const QPoint & pos) const
将父类窗口坐标转换成当前窗口坐标
Translates the parent widget coordinate posto widget coordinates. Same as mapFromGlobal() if the widget has no parent.
8. QPoint QWidget::mapTo(const QWidget * parent, const QPoint &pos) const
将当前窗口坐标转换成指定parent坐标。
Translates the widget coordinate pos to thecoordinate system of parent. The parent must not be 0 and must be a parent ofthe calling widget. See also mapFrom(), mapToParent(), mapToGlobal(), andunderMouse().
9. QWidget::pos() : QPoint
这个属性获得的是当前目前控件在父窗口中的位置,
This property holds the position of thewidget within its parent widget.
If the widget is a window, the position isthat of the widget on the desktop, including its frame.
When changing the position, the widget, ifvisible, receives a move event (moveEvent()) immediately. If the widget is notcurrently visible, it is guaranteed to receive an event before it is shown.
By default, this property contains aposition that refers to the origin.
Warning: Calling move() or setGeometry()inside moveEvent() can lead to infinite recursion.
See the Window Geometry documentation foran overview of geometry issues with windows.
10. const QPointF &QMouseEvent::screenPos() const
Returns the position of the mouse cursor asa QPointF, relative to the screen that received the event.
和QPoint QMouseEvent::globalPos() 值相同,但是类型更高精度的QPointF
This function was introduced in Qt 5.0.
11. QCursor::pos() == QMouseEvent::globalPos() 都是全局坐标
12. 将鼠标的坐标转换成全局坐标。
QMouseEvent::globalPos() == ui.posBtn->mapToGlobal(ui.posBtn->pos());
13. 将全局坐标(鼠标当前坐标,QCursor::pos())直接转换成当前窗口相对坐标
ui.posBtn->mapFromGlobal(QCursor::pos());
- Qt获取控件位置坐标详解
- Qt获取控件位置,坐标总结
- Qt获取控件位置,坐标总结
- Qt获取控件位置,坐标总结
- Qt获取控件位置,坐标总结
- Qt获取控件位置,坐标总结
- mfc控件位置坐标获取
- js获取控件坐标以及位置定位
- Android如何获取子控件位置坐标
- Android 获取控件的坐标位置
- 如何获取控件的坐标位置
- 获取View点击位置坐标(详解)
- Qt如何获取控件的坐标
- android设置控件的位置以及获取控件的坐标
- MFC控件坐标位置
- 获取一个控件相对于父窗口的坐标位置
- Silverlight如何获取控件的屏幕坐标位置
- android获取屏幕尺寸,标题栏,状态栏高度,控件位置坐标
- 【图像处理】双峰阈值分割法
- SpaceX成功实现“二手火箭”再发射!马斯克又创造了历史
- 更轻更智能 智云Smooth-Q手机稳定器799震撼发售
- 苹果AI总监谈人工智能:对强化学习很感兴趣
- Windows7下搭建Qt 64bit编程环境
- Qt获取控件位置坐标详解
- 系统日志管理
- JS中的事件委托
- 问题ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory的解决方案
- 站在秋天的路口,等风,也等你!
- GENERATIVE ADVERSARIAL NETWORKS FOR IMAGE STEGANOGRAPHY
- 手机前置3D摄像头,噱头还是刚需?
- 微信拓展欧美市场:吸引奢侈品牌,推广支付服务
- Adobe也玩“PPAP”,两图合并带来新风格