当前位置:网站首页>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
边栏推荐
- The connection and solution between the shortest Hamilton path and the traveling salesman problem
- Arduino 控制的 RGB LED 无限镜
- 1.14 - 流水线
- Wazuh開源主機安全解决方案的簡介與使用體驗
- Overview of variable resistors - structure, operation and different applications
- 927. Trisection simulation
- [rust notes] 16 input and output (Part 2)
- 【Rust 笔记】15-字符串与文本(下)
- 可变电阻器概述——结构、工作和不同应用
- Sqlmap tutorial (II) practical skills I
猜你喜欢
Liunx starts redis
数据可视化图表总结(一)
QQ电脑版取消转义符输入表情
快速使用Amazon MemoryDB并构建你专属的Redis内存数据库
SQLMAP使用教程(二)实战技巧一
Typical use cases for knapsacks, queues, and stacks
Analysis of backdoor vulnerability in remote code execution penetration test / / phpstudy of national game title of national secondary vocational network security B module
【实战技能】如何做好技术培训?
【云原生】微服务之Feign自定义配置的记录
Appium foundation - use the first demo of appium
随机推荐
【Rust 笔记】15-字符串与文本(下)
1040 Longest Symmetric String
Wazuh开源主机安全解决方案的简介与使用体验
1040 Longest Symmetric String
RGB LED infinite mirror controlled by Arduino
Analysis of backdoor vulnerability in remote code execution penetration test / / phpstudy of national game title of national secondary vocational network security B module
数据可视化图表总结(一)
CPU内核和逻辑处理器的区别
【Rust 笔记】16-输入与输出(下)
【Rust 笔记】17-并发(上)
1039 Course List for Student
Daily question 2006 Number of pairs whose absolute value of difference is k
Simple knapsack, queue and stack with deque
One question per day 1765 The highest point in the map
[practical skills] technical management of managers with non-technical background
【Rust 笔记】16-输入与输出(上)
Dichotomy, discretization, etc
Appium automation test foundation - Summary of appium test environment construction
6. Logistic model
[practical skills] how to do a good job in technical training?