当前位置:网站首页>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();//获取当前鼠标位置边栏推荐
- Graduation project of game mall
- Control unit
- Add level control and logger level control of Solon logging plug-in
- Light a light with stm32
- Scope of inline symbol
- 剑指 Offer 35.复杂链表的复制
- CF1634E Fair Share
- Introduction et expérience de wazuh open source host Security Solution
- Haut OJ 1401: praise energy
- Codeforces Round #716 (Div. 2) D. Cut and Stick
猜你喜欢

Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail

剑指 Offer 35.复杂链表的复制

7. Processing the input of multidimensional features

剑指 Offer 09. 用两个栈实现队列

Talking about JVM (frequent interview)

Light a light with stm32

On the characteristics of technology entrepreneurs from Dijkstra's Turing Award speech

Time of process

CCPC Weihai 2021m eight hundred and ten thousand nine hundred and seventy-five

How to adjust bugs in general projects ----- take you through the whole process by hand
随机推荐
二十六、文件系统API(设备在应用间的共享;目录和文件API)
数仓项目的集群脚本
全国中职网络安全B模块之国赛题远程代码执行渗透测试 //PHPstudy的后门漏洞分析
过拟合与正则化
Haut OJ 2021 freshmen week II reflection summary
读者写者模型
Summary of Haut OJ 2021 freshman week
Mysql database (I)
CF1634E Fair Share
剑指 Offer 53 - II. 0~n-1中缺失的数字
Smart construction site "hydropower energy consumption online monitoring system"
Sword finger offer 05 Replace spaces
CF1637E Best Pair
Add level control and logger level control of Solon logging plug-in
剑指 Offer 53 - I. 在排序数组中查找数字 I
Acwing 4301. Truncated sequence
A misunderstanding about the console window
2022 pole technology communication arm virtual hardware accelerates the development of Internet of things software
动漫评分数据分析与可视化 与 IT行业招聘数据分析与可视化
Brief introduction to tcp/ip protocol stack