当前位置:网站首页>Currently clicked button and current mouse coordinates in QT judgment interface
Currently clicked button and current mouse coordinates in QT judgment interface
2022-07-05 06:11:00 【my_ angle2016】
1.QObject::sender( ) Returns the pointer of the object that sent the signal , The return type is QObject* . You can use qobject_cast The dynamic type is converted into the corresponding object of sending information ( The base class of the object class needs to have QObject).
QObject::objectName( ) Returns the name of the object (QString)
QPushButton*btn = qobject_cast<QPushButton*>(sender());// Get the object that transmits the signal
if(" Button object name "==btn->objectName()){// If you get an object
//...
}
2. QMouseEvent Two kinds of coordinate systems , One is window coordinates ( Relative coordinates ), One is the display coordinates ( Global coordinates )
QPointQMouseEvent::globalPos();// Window coordinates , This is to return the global coordinates of the mouse
QPointQCursor::pos()[static];// Returns the global coordinates relative to the display
QPointQMouseEvent::pos();// Return relative to this widget The location of
QPointQWidget::pos();// This property gets the current position of the control in the parent window
constQPointF&QMouseEvent::screenPos()const;// and QPoint QMouseEvent::globalPos() Same value , But the type is more precise QPointF
QPointQWidget::mapToGlobal(constQPoint& pos)const;// Convert window coordinates into display coordinates
QPointQWidget::mapFromGlobal(constQPoint& pos)const;// Convert the display coordinates into window coordinates
QPointQWidget::mapToParent(constQPoint& pos)const;// Get the window coordinates pos Convert to parent class widget Coordinates of
QPointQWidget::mapFromParent(constQPoint& pos)const;// Convert the parent window coordinates to the current window coordinates
QPointQWidget::mapTo(constQWidget* parent,constQPoint& pos)const;// Convert the current window coordinates to the specified parent coordinate
// You can also use :
Qpoint pt=cursor().pos();// Get the current mouse position
边栏推荐
- MIT-6874-Deep Learning in the Life Sciences Week 7
- QQ computer version cancels escape character input expression
- Real time clock (RTC)
- Leetcode-6108: decrypt messages
- Time of process
- Analysis of backdoor vulnerability in remote code execution penetration test / / phpstudy of national game title of national secondary vocational network security B module
- Smart construction site "hydropower energy consumption online monitoring system"
- [practical skills] technical management of managers with non-technical background
- 2022年贵州省职业院校技能大赛中职组网络安全赛项规程
- Overview of variable resistors - structure, operation and different applications
猜你喜欢
LaMDA 不可能觉醒吗?
MIT-6874-Deep Learning in the Life Sciences Week 7
【实战技能】如何做好技术培训?
API related to TCP connection
Doing SQL performance optimization is really eye-catching
Data visualization chart summary (II)
SQLMAP使用教程(二)实战技巧一
数据可视化图表总结(一)
[practical skills] technical management of managers with non-technical background
leetcode-6111:螺旋矩阵 IV
随机推荐
Wazuh開源主機安全解决方案的簡介與使用體驗
SPI 详解
leetcode-31:下一个排列
[rust notes] 16 input and output (Part 1)
1.13 - RISC/CISC
Introduction to LVS [unfinished (semi-finished products)]
一些工具的记录2022
927. Trisection simulation
Transform optimization problems into decision-making problems
Appium基础 — 使用Appium的第一个Demo
智慧工地“水电能耗在线监测系统”
Redis publish subscribe command line implementation
Leetcode-556: the next larger element III
Simple knapsack, queue and stack with deque
对for(var i = 0;i < 5;i++) {setTimeout(() => console.log(i),1000)}的深入分析
Personal developed penetration testing tool Satania v1.2 update
Daily question 2006 Number of pairs whose absolute value of difference is k
【Rust 笔记】13-迭代器(中)
2022年貴州省職業院校技能大賽中職組網絡安全賽項規程
中职网络安全技能竞赛——广西区赛中间件渗透测试教程文章