当前位置:网站首页>QT判断界面当前点击的按钮和当前鼠标坐标
QT判断界面当前点击的按钮和当前鼠标坐标
2022-07-05 05:43:00 【my_angle2016】
1.QObject::sender( ) 返回发送信号的对象的指针,返回类型为QObject* 。可使用qobject_cast动态类型转换成对应的发送信息的对象(对象类的基类中需要有QObject)。
QObject::objectName( ) 返回对象的名称(QString)
QPushButton*btn = qobject_cast<QPushButton*>(sender());//获取发射信号的对象
if("按钮对象名"==btn->objectName()){//如果获取到对象
//...
}2. QMouseEvent中两类坐标系统,一类是窗口坐标(相对坐标),一类是显示器坐标(全局坐标)
QPointQMouseEvent::globalPos();//窗口坐标,这个是返回鼠标的全局坐标
QPointQCursor::pos()[static];//返回相对显示器的全局坐标
QPointQMouseEvent::pos();//返回相对这个widget的位置
QPointQWidget::pos();//这个属性获得的是当前目前控件在父窗口中的位置
constQPointF&QMouseEvent::screenPos()const;//和QPoint QMouseEvent::globalPos() 值相同,但是类型更高精度的QPointF
QPointQWidget::mapToGlobal(constQPoint& pos)const;//将窗口坐标转换成显示器坐标
QPointQWidget::mapFromGlobal(constQPoint& pos)const;//将显示器坐标转换成窗口坐标
QPointQWidget::mapToParent(constQPoint& pos)const;//将窗口坐标获得的pos转换成父类widget的坐标
QPointQWidget::mapFromParent(constQPoint& pos)const;//将父类窗口坐标转换成当前窗口坐标
QPointQWidget::mapTo(constQWidget* parent,constQPoint& pos)const;//将当前窗口坐标转换成指定parent坐标
//也可使用:
Qpoint pt=cursor().pos();//获取当前鼠标位置边栏推荐
- 2022年贵州省职业院校技能大赛中职组网络安全赛项规程
- Daily question - Search two-dimensional matrix PS two-dimensional array search
- How to adjust bugs in general projects ----- take you through the whole process by hand
- lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
- Detailed explanation of expression (csp-j 2021 expr) topic
- 6. Logistic model
- Introduction et expérience de wazuh open source host Security Solution
- Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
- Fried chicken nuggets and fifa22
- Personal developed penetration testing tool Satania v1.2 update
猜你喜欢

CF1634 F. Fibonacci Additions

Gbase database helps the development of digital finance in the Bay Area

用STM32点个灯

从Dijkstra的图灵奖演讲论科技创业者特点

API related to TCP connection

Fried chicken nuggets and fifa22

Individual game 12

Full Permutation Code (recursive writing)
![[jailhouse article] look mum, no VM exits](/img/fe/87e0851d243f14dff96ef1bc350e50.png)
[jailhouse article] look mum, no VM exits

剑指 Offer 06.从头到尾打印链表
随机推荐
Scope of inline symbol
智慧工地“水电能耗在线监测系统”
Gbase database helps the development of digital finance in the Bay Area
【实战技能】如何做好技术培训?
Codeforces Round #715 (Div. 2) D. Binary Literature
2020ccpc Qinhuangdao J - Kingdom's power
CF1637E Best Pair
API related to TCP connection
卷积神经网络简介
Csp-j-2020-excellent split multiple solutions
A new micro ORM open source framework
Detailed explanation of expression (csp-j 2021 expr) topic
【Jailhouse 文章】Jailhouse Hypervisor
Daily question 1688 Number of matches in the competition
剑指 Offer 04. 二维数组中的查找
Chapter 6 data flow modeling - after class exercises
Pointnet++ learning
Implement a fixed capacity stack
2022 pole technology communication arm virtual hardware accelerates the development of Internet of things software
Use of room database