当前位置:网站首页>QT笔记——Q_Q 和Q_D 学习
QT笔记——Q_Q 和Q_D 学习
2022-07-26 03:10:00 【旧街凉风°】
在源码中,我们会经常看到Q_Q 和 Q_D 这两个东西 ,很好奇,就去网上搜索了一些和 查看了一些源码 部分
Q_D相关宏
#define Q_D(Class) Class##Private * const d = d_func()
Q_D(Test)
//展开后 是一个 私有类的指针常量
TestPrivate * const d = d_func();
d_func()
QScopedPointer<QPainterPathPrivate, QPainterPathPrivateDeleter> d_ptr;
QPainterPathData *d_func() const {
return reinterpret_cast<QPainterPathData *>(d_ptr.data()); }
Q_DECLARE_PRIVATE(Class)
#define Q_DECLARE_PRIVATE(Class) \ inline Class##Private* d_func() \ {
Q_CAST_IGNORE_ALIGN(return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr));) } \ inline const Class##Private* d_func() const \ {
Q_CAST_IGNORE_ALIGN(return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr));) } \ friend class Class##Private;
Q_DECLARE_PRIVATE(Test)
//展开后
inline TestPrivate* d_func() {
return reinterpret_cast<TestPrivate *>(qGetPtrHelper(d_ptr));}
inline const TestPrivate* d_func() const{
return reinterpret_cast<const TestPrivate *>(qGetPtrHelper(d_ptr));}
friend class TestPrivate;
Q_Q相关宏
#define Q_Q(Class) Class * const q = q_func()
**Q_DECLARE_PUBLIC(Class) **
#define Q_DECLARE_PUBLIC(Class) \ inline Class* q_func() {
return static_cast<Class *>(q_ptr); } \ inline const Class* q_func() const {
return static_cast<const Class *>(q_ptr); } \ friend class Class;
Q_DECLARE_PUBLIC(Test)
inline Test* q_func() {
return static_cast<Test*>(q_ptr); }
inline const Test* q_func() const {
return static_cast<const Test*>(q_ptr); }
friend class Test;
边栏推荐
- C language layered understanding (C language function)
- [NOIP2001 普及组]装箱问题
- 一篇文章让你理解 云原生 容器化相关
- Continuous delivery and Devops are good friends
- 班级里有一群学生考试结果出来了,考了语文和数学两门,请筛选出总分是第一的同学
- Usage of fuser and lsof
- Functions and usage of snownlp Library
- STM32——PWM学习笔记
- GoLang日志编程系统
- FPGA_ Initial use process of vivado software_ Ultra detailed
猜你喜欢
随机推荐
[sql] case expression
c语言分层理解(c语言函数)
[Yuri crack man] brings you easy understanding - deep copy and shallow copy
An article allows you to understand the relevance of cloud native containerization
经典面试问题——OOP语言的三大特征
Win11麦克风权限的开启方法
Canvas - drawing pictures - dynamic drawing production
Opencv annotates the image (picture frame + writing)
Service gateway (zuul)
[sql] usage of self connection
堆内存与栈内存的区别?
Canvas -- draw text -- modification of pie chart
在混合云中管理数据库:八个关键注意事项
Type the URL to the web page display. What happened during this period?
Unity快速搭建城市场景
[C language] deeply understand integer lifting and arithmetic conversion
How to install with USB flash disk?
Safety margin of mass consumption
【无标题】
What is the difference between heap memory and stack memory?




![[sql] case expression](/img/05/1bbb0b5099443f7ce5f5511703477e.png)




