Results 1 to 5 of 5

Thread: Share header file between projects

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Share header file between projects

    What's the right way to share a header file between projects using Qt creator?

    Should I add the file to BOTH projects and just leave it one or the other's directory structure?

    I'm using svn. Will the file commit if I commit either project?

    Thanks!

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Share header file between projects

    I am assuming you have source that goes with that header you'd like to share. I would add the header/source as a subproject to both projects which would allow you to share bug fixes or checkout different versions for each project, etc.

    I would not include the header file directly in both projects. If you did that, you'd have to manually keep your other project in sync if you fixed a bug, etc.

    Make sense?

    BTW, I switched to git years ago, it really is better IMHO, so you might want to jump on the bandwagon too!

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Share header file between projects

    Quote Originally Posted by davethomaspilot View Post
    What's the right way to share a header file between projects using Qt creator?
    A common approach is to have a .pri file at the location of the code you want to share and include that in your .pro file.
    The .pri file then takes care of adding paths to the respective qmake variables.

    Whether the code gets built into each application or is built as a library and linked to the applications is a different choice.

    Quote Originally Posted by davethomaspilot View Post
    I'm using svn. Will the file commit if I commit either project?
    SVN commits anything that is in or below the directory the commit is triggered in.
    Anything outside that subtree is ignored.

    Cheers,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    davethomaspilot (1st April 2015)

  5. #4
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Share header file between projects

    By "subproject", you mean just another project?

    The header file is in a completely different subdirectory? Then put that directory in the include path, or reference them with a relative path from source files in either porject?

    I've heard git is better, but I can't imagine what would matter enough to bother with learning something new. Just one person is working on the source (me), so it doesn't seem worth the bother to switch.

    I wasn't aware of a ".pri" file. So, I'll have to read about that.

    Thanks.

  6. #5
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Share header file between projects

    Quote Originally Posted by davethomaspilot View Post
    By "subproject", you mean just another project?
    I mean subproject as in an external SVN subproject as described here:

    http://svnbook.red-bean.com/en/1.7/s...externals.html

Similar Threads

  1. Why don't Qt Creator projects recompile after header changes?
    By tksharpless in forum Qt Programming
    Replies: 5
    Last Post: 19th October 2011, 18:20
  2. Share my qmake project file
    By ibingow in forum Qt Tools
    Replies: 0
    Last Post: 30th August 2011, 10:19
  3. Replies: 1
    Last Post: 24th August 2011, 14:51
  4. Replies: 1
    Last Post: 15th June 2010, 14:25
  5. Missing file errors when Rebuilding example projects
    By Thomas Wrobel in forum Newbie
    Replies: 1
    Last Post: 8th January 2010, 13:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.