Unsolved When I should do use the _p.h header file.
-
Hi guys!
Currently, I read some source code of qt creator, I found that there are
amount of _P.h header file existed in qt creator. However, there are few file created without this pattern. I would like to perceive whether there are criterions for this idiom, may some bro give a interpretation in details ,thx! -
The *_p.h files are the declaration of a private implementation, PIMPL, of the related class e.g., qlocale.h and qlocale_p.h. PIMPL is used for varied reasons, for example:
- Make maintaining binary compatibility across versions easier. So, for example, code written and linked against Qt 5.12 can use a Qt 5.15 library set even if the internal implementation of some classes is wildly different.
- Make implementation opaque, with only a public API header published with a binary library.
Qt does both. Have a read here for example.