Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Q_D macro do in Qt

Tags:

macros

qt

I am exploring Qt source code and came across this Q_D macro. Could some one please explain what it does?

Almost all the time it should return a widget of the type given as a parameter which is the d variable. Need more clarification on this.

like image 669
Tharanga Avatar asked Jul 27 '11 09:07

Tharanga


1 Answers

In short, Qt uses private implementation to manage data. For classes that do this, there usually is an X class and an XPrivate class. The Q_D macro defines the "d" pointer so if you write d->whatever, you have access to that private data part.

This article should pretty much cover most of your questions:

https://wiki.qt.io/D-Pointer

like image 89
Tim Meyer Avatar answered Sep 30 '22 23:09

Tim Meyer