当前位置:网站首页>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
边栏推荐
- Appium automation test foundation - Summary of appium test environment construction
- Groupbykey() and reducebykey() and combinebykey() in spark
- SQLMAP使用教程(二)实战技巧一
- Data visualization chart summary (II)
- CPU内核和逻辑处理器的区别
- 多屏电脑截屏会把多屏连着截下来,而不是只截当前屏
- leetcode-1200:最小绝对差
- 1041 Be Unique
- Flutter Web 硬件键盘监听
- 做 SQL 性能优化真是让人干瞪眼
猜你喜欢
1.13 - RISC/CISC
MIT-6874-Deep Learning in the Life Sciences Week 7
Data visualization chart summary (I)
Erreur de connexion Navicat à la base de données Oracle Ora - 28547 ou Ora - 03135
Appium automation test foundation - Summary of appium test environment construction
[jailhouse article] look mum, no VM exits
The connection and solution between the shortest Hamilton path and the traveling salesman problem
Dynamic planning solution ideas and summary (30000 words)
6. Logistic model
数据可视化图表总结(二)
随机推荐
实时时钟 (RTC)
多屏电脑截屏会把多屏连着截下来,而不是只截当前屏
liunx启动redis
TypeScript 基础讲解
The sum of the unique elements of the daily question
QQ电脑版取消转义符输入表情
Appium自动化测试基础 — Appium测试环境搭建总结
PC register
Analysis of backdoor vulnerability in remote code execution penetration test / / phpstudy of national game title of national secondary vocational network security B module
打印机脱机时一种容易被忽略的原因
Wazuh開源主機安全解决方案的簡介與使用體驗
【Rust 笔记】14-集合(下)
Leetcode-31: next spread
Erreur de connexion Navicat à la base de données Oracle Ora - 28547 ou Ora - 03135
leetcode-3:无重复字符的最长子串
One question per day 2047 Number of valid words in the sentence
Overview of variable resistors - structure, operation and different applications
redis发布订阅命令行实现
开源存储这么香,为何我们还要坚持自研?
A reason that is easy to be ignored when the printer is offline