当前位置:网站首页>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();//获取当前鼠标位置
边栏推荐
- 游戏商城毕业设计
- Animation scoring data analysis and visualization and it industry recruitment data analysis and visualization
- Drawing dynamic 3D circle with pure C language
- [cloud native] record of feign custom configuration of microservices
- Reader writer model
- 剑指 Offer 58 - II. 左旋转字符串
- 使用Electron开发桌面应用
- 26、 File system API (device sharing between applications; directory and file API)
- Add level control and logger level control of Solon logging plug-in
- Mysql database (I)
猜你喜欢
Some common problems in the assessment of network engineers: WLAN, BGP, switch
Fried chicken nuggets and fifa22
A new micro ORM open source framework
【实战技能】非技术背景经理的技术管理
Reader writer model
Implement an iterative stack
lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
从Dijkstra的图灵奖演讲论科技创业者特点
个人开发的渗透测试工具Satania v1.2更新
Codeforces round 712 (Div. 2) d. 3-coloring (construction)
随机推荐
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
CF1634E Fair Share
Individual game 12
Little known skills of Task Manager
Gbase database helps the development of digital finance in the Bay Area
Analysis of backdoor vulnerability in remote code execution penetration test / / phpstudy of national game title of national secondary vocational network security B module
A problem and solution of recording QT memory leakage
How many checks does kubedm series-01-preflight have
Web APIs DOM node
A misunderstanding about the console window
剑指 Offer 06.从头到尾打印链表
“磐云杯”中职网络安全技能大赛A模块新题
Configuration and startup of kubedm series-02-kubelet
Simply sort out the types of sockets
Implement a fixed capacity stack
【云原生】微服务之Feign自定义配置的记录
Over fitting and regularization
R语言【数据集的导入导出】
Sword finger offer 53 - I. find the number I in the sorted array
How can the Solon framework easily obtain the response time of each request?