PDA

View Full Version : What are the private classes in Qt header files & how they useful ?



prasad_N
8th April 2016, 20:16
Hi,
When I go to Qt header file, I often see some private classes in header files. ex: in QAbstractItemModel we will see QAbstractItemModelPrivate.
What are this private classes actually & what is the use of this classes ?
is this concept specific to Qt or Some design pattern ?

anda_skoa
8th April 2016, 22:34
That's the PIMPL or D-Pointer idiom
https://en.wikipedia.org/wiki/Opaque_pointer

It is used to maintain binary compatibility over the long time of a Qt major version, i.e. to avoid binary incompatibility issues (https://community.kde.org/Policies/Binary_Compatibility_Issues_With_C++) when classes need new or different data as they evolve.

Cheers,
_