In the Qt GUI sources, what do the macros like Q_D & Q_Q do?
In the Qt GUI sources, what do the macros like Q_D & Q_Q do?
First one obtains a "d-pointer" that points to the private part of the implementation.Qt Code:
#define Q_D(Class) Class##Private * const d = d_func() #define Q_Q(Class) Class * const q = q_func()To copy to clipboard, switch view to plain text mode
The second one obtains a pointer to the public part of the implemention.From "Data Sharing with Class" by Jasmin Blanchette
The term "d-pointer" was coined by Arnt Gulbrandsen and later adopted by Qt and KDE programmers. It is called "Pimpl" (Pointer to implementation) in the book Exceptional C++, and "Cheshire Cat" in Design Patterns.
Bookmarks