当前位置:网站首页>qobject_ Cast usage
qobject_ Cast usage
2022-07-01 19:47:00 【Beginner Xiaobai Lu】
qobject_cast() Dynamic transformation QObject The type of the class .
T qobject_cast ( QObject * object )
This method returns object Downward transformation T, If the transformation is not successful, return 0, If the incoming object Itself is 0 Then return to 0
Example :
QObject *obj = new QTimer; // QTimer inherits QObject
QTimer *timer = qobject_cast<QTimer *>(obj);
// timer == (QObject *)obj
QAbstractButton *button = qobject_cast<QAbstractButton *>(obj);
// button == nullptr
Usage restriction :
T Type must inherit from QObject
There must be... In the declaration Q_OBJECT macro .
usage –sender() function
QPushButton *button_tmp=qobject_cast<QPushButton *>(sender());
When one Object emit One signal When , It's a sender, The system will record who is currently emit Out of this signal Of , So you are corresponding slot You can pass through sender() Get who is currently invoke Your slot, The corresponding is QObject->d->sender.
边栏推荐
- Simplified pinduoduo product data
- 【AI服务器搭建】CUDA环境
- [research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached
- GetMessage底层机制分析
- Interview question 16.16 Partial sorting - Double finger needling
- GB28181之SIP协议
- 【sql优化】with as 和 临时表的区别
- 通过js实现金字塔(星号金字塔,回文对称数字金字塔)
- [research materials] Huawei Technology ICT 2021: at the beginning of the "Yuan" year, the industry is "new" -- download attached
- [exercise] HashSet
猜你喜欢
[Mori city] random talk on GIS data (I)
Image acquisition and playback of coaxpress high speed camera based on pxie interface
JVM内存模型
Technology T3 domestic platform! Successfully equipped with "Yihui domestic real-time system sylixos"
Crunch简介、安装,使用Crunch制作密码字典
解决VSCode下载慢或下载失败的问题
【AI服务器搭建】CUDA环境
Optaplanner learning notes (I) case cloud balance
Procédure de mesure du capteur d'accord vibrant par le module d'acquisition d'accord vibrant
GC垃圾回收
随机推荐
[research materials] Huawei Technology ICT 2021: at the beginning of the "Yuan" year, the industry is "new" -- download attached
Collation of open source protocols of open source frameworks commonly used in Web Development
IPv4 address, subnet mask, gateway
大厂音视频职位面试题目--今日头条
新窗口打开页面-window.open
Basic use of MySQL
Oracle物理体系结构
Ffmpeg audio related commands
Proxy in ES6
GB28181的NAT穿透
Anaconda安装虚拟环境到指定路径
事务隔离级别 gap锁 死锁
Wechat applet navigator has a shadow after clicking. Remove the shadow effect of navigator
ES6中的代理proxy
Introduction and installation of crunch, and making password dictionary with crunch
Use the uni app demo provided by Huanxin to quickly realize one-on-one chat
Is Dao safe? Build finance encountered a malicious governance takeover and was looted!
Time series analysis using kibana timelion
servlet知识点
Basic knowledge of audio coding and decoding