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. Qt why use .h and .cpp rather than .hpp?
Forum Updated to NodeBB v4.3 + New Features

Qt why use .h and .cpp rather than .hpp?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 2.5k Views
  • 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.
  • L Offline
    L Offline
    Limer
    wrote on 24 Jan 2019, 08:46 last edited by
    #1

    Today I came across this post https://stackoverflow.com/questions/152555/h-or-hpp-for-your-class-definitions ,
    Qt is a C++ framework, and I saw all of them are *.h and *.cpp in source code.
    So, is there any other reasons not to use *.hpp?

    A 1 Reply Last reply 24 Jan 2019, 09:04
    0
    • L Limer
      24 Jan 2019, 08:46

      Today I came across this post https://stackoverflow.com/questions/152555/h-or-hpp-for-your-class-definitions ,
      Qt is a C++ framework, and I saw all of them are *.h and *.cpp in source code.
      So, is there any other reasons not to use *.hpp?

      A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 24 Jan 2019, 09:04 last edited by
      #2

      @Limer

      I think this question can be answered like most similar questions: Historic reasons.

      Also note that all the official includes, like #include <QString> , have no extension at all.

      Qt has to stay free or it will die.

      1 Reply Last reply
      6
      • V Offline
        V Offline
        VRonin
        wrote on 24 Jan 2019, 09:25 last edited by
        #3

        Header files are not compiled so it doesn't really matter, it's the content of the .cpp file that includes them to determine if they are considered C or C++.
        It's pure flavour.
        I normally use .hpp if the header contains definitions (like is the case with templates) and .h if it just contains declarations. The idea is to have some kind of a warning that if you include .hpp in multiple .cpp you are potentially compiling the same code twice. Once again it's just an opinion, you are free to call them as you prefer

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        6
        • L Offline
          L Offline
          Limer
          wrote on 24 Jan 2019, 09:53 last edited by
          #4

          Thanks a lot for your warm response. I see..

          1 Reply Last reply
          0

          1/4

          24 Jan 2019, 08:46

          • Login

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