当前位置:网站首页>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 边栏推荐
- leetcode-556:下一个更大元素 III
- QQ computer version cancels escape character input expression
- Matrixdb V4.5.0 was launched with a new mars2 storage engine!
- 【Rust 笔记】14-集合(下)
- LeetCode 0108.将有序数组转换为二叉搜索树 - 数组中值为根,中值左右分别为左右子树
- 1.14 - 流水线
- Shutter web hardware keyboard monitoring
- 多屏电脑截屏会把多屏连着截下来,而不是只截当前屏
- 开源存储这么香,为何我们还要坚持自研?
- leetcode-22:括号生成
猜你喜欢

Wazuh開源主機安全解决方案的簡介與使用體驗

传统数据库逐渐“难适应”,云原生数据库脱颖而出

Full Permutation Code (recursive writing)

liunx启动redis

SPI details

Appium自动化测试基础 — Appium测试环境搭建总结

Error ora-28547 or ora-03135 when Navicat connects to Oracle Database

Liunx starts redis

Implement an iterative stack

Traditional databases are gradually "difficult to adapt", and cloud native databases stand out
随机推荐
[rust notes] 17 concurrent (Part 2)
Introduction et expérience de wazuh open source host Security Solution
LaMDA 不可能觉醒吗?
[rust notes] 14 set (Part 2)
一些工具的记录2022
leetcode-6109:知道秘密的人数
【Rust 笔记】15-字符串与文本(下)
redis发布订阅命令行实现
Wazuh開源主機安全解决方案的簡介與使用體驗
One question per day 1765 The highest point in the map
Leetcode-6109: number of people who know secrets
开源存储这么香,为何我们还要坚持自研?
Individual game 12
Daily question 2006 Number of pairs whose absolute value of difference is k
LeetCode 0108.将有序数组转换为二叉搜索树 - 数组中值为根,中值左右分别为左右子树
Sqlmap tutorial (1)
对for(var i = 0;i < 5;i++) {setTimeout(() => console.log(i),1000)}的深入分析
【Rust 笔记】17-并发(上)
Traditional databases are gradually "difficult to adapt", and cloud native databases stand out
1039 Course List for Student