当前位置:网站首页>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();//获取当前鼠标位置
边栏推荐
- YOLOv5-Shufflenetv2
- Simply sort out the types of sockets
- Graduation project of game mall
- Educational codeforces round 109 (rated for Div. 2) C. robot collisions D. armchairs
- [practical skills] technical management of managers with non-technical background
- Solution to the palindrome string (Luogu p5041 haoi2009)
- Sword finger offer 53 - ii Missing numbers from 0 to n-1
- SAP-修改系统表数据的方法
- AtCoder Grand Contest 013 E - Placing Squares
- Zzulioj 1673: b: clever characters???
猜你喜欢
lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
Scope of inline symbol
F - Two Exam(AtCoder Beginner Contest 238)
Analysis of backdoor vulnerability in remote code execution penetration test / / phpstudy of national game title of national secondary vocational network security B module
网络工程师考核的一些常见的问题:WLAN、BGP、交换机
Brief introduction to tcp/ip protocol stack
[jailhouse article] performance measurements for hypervisors on embedded ARM processors
全国中职网络安全B模块之国赛题远程代码执行渗透测试 //PHPstudy的后门漏洞分析
Using HashMap to realize simple cache
[cloud native] record of feign custom configuration of microservices
随机推荐
High precision subtraction
AtCoder Grand Contest 013 E - Placing Squares
Detailed explanation of expression (csp-j 2021 expr) topic
lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
【Jailhouse 文章】Look Mum, no VM Exits
2022年贵州省职业院校技能大赛中职组网络安全赛项规程
Sword finger offer 04 Search in two-dimensional array
Control unit
剑指 Offer 53 - II. 0~n-1中缺失的数字
Codeforces Round #732 (Div. 2) D. AquaMoon and Chess
Fried chicken nuggets and fifa22
Sword finger offer 09 Implementing queues with two stacks
Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
How can the Solon framework easily obtain the response time of each request?
[cloud native] record of feign custom configuration of microservices
Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
Little known skills of Task Manager
软件测试 -- 0 序
Add level control and logger level control of Solon logging plug-in
Common optimization methods