Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. When I should do use the _p.h header file.
Qt 6.11 is out! See what's new in the release blog

When I should do use the _p.h header file.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Silent_Alex
    wrote on last edited by Silent_Alex
    #1

    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!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved