Results 1 to 4 of 4

Thread: How to setup paths in a pro file

  1. #1
    Join Date
    Aug 2012
    Location
    The Netherland
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to setup paths in a pro file

    Hi Guys,

    How do I do the following;

    This is a simplification of the map setup I have so far

    Qt Code:
    1. projects
    2. project_1
    3. file_a.cpp
    4. file_a.h
    5. file_b.cpp
    6. file_b.h
    To copy to clipboard, switch view to plain text mode 

    and now I want to do the following

    Qt Code:
    1. projects
    2. project_1
    3. file_a.cpp
    4. file_a.h
    5. shared
    6. file_b.cpp
    7. file_b.h
    8. project_2
    9. file_c.cpp
    10. file_c.h
    To copy to clipboard, switch view to plain text mode 

    So I want to share file_b over two projects. Everytime I open project 1 or 2 I get to file_b and if I make changes in project 1, file_b is updated so project 2 can also make use of the new functionality.

    How do I proceed to make this possible?

    Many thanks in advance!
    Rob

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to setup paths in a pro file

    You could simply add the file_b.* to both the projects i.e to project_1 and project_2.
    or
    If project_1 and project_2 are related, i.e. you generally build/rebuild them togeather then you make them as sub-directory projects with a top level project
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to setup paths in a pro file

    One way to arrange it:
    Qt Code:
    1. projects
    2. project_1
    3. project_1.pro // see below
    4. file_a.cpp
    5. file_a.h
    6. shared
    7. shared.pri // see below
    8. file_b.cpp
    9. file_b.h
    10. project_2
    11. project_2.pro // see below
    12. file_c.cpp
    13. file_c.h
    To copy to clipboard, switch view to plain text mode 

    In the project files:
    qmake Code:
    1. TEMPLATE = app
    2. ...
    3. include(../shared/shared.pri)
    To copy to clipboard, switch view to plain text mode 
    and in shared.pri
    qmake Code:
    1. INCLUDEPATH += $${PWD}
    2. DEPENDPATH += $${PWD}
    3. HEADERS += $${PWD}/file_b.h
    4. SOURCES += $${PWD}/file_b.cpp
    To copy to clipboard, switch view to plain text mode 
    Then when you add or remove files from shared the other projects automatically get them. file_a.cpp can directly #include "file_b.h" without worrying about relative paths etc.


    Alternatively, you could make "shared" a static library project and use:
    qmake Code:
    1. LIBS += -L../shared -lshared
    To copy to clipboard, switch view to plain text mode 
    in projects a and b.

    Lots of variations on the theme.
    Last edited by Lykurg; 12th February 2013 at 23:48. Reason: closed last [code] tag

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

    robsofmar (13th February 2013)

  5. #4
    Join Date
    Aug 2012
    Location
    The Netherland
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to setup paths in a pro file

    Thanks to your input I got it working the way I want it now. Thx a lot!

Similar Threads

  1. Replies: 2
    Last Post: 4th April 2012, 00:53
  2. Problem with file paths in XP
    By IndikaU in forum Newbie
    Replies: 13
    Last Post: 14th October 2011, 10:12
  3. Replies: 3
    Last Post: 27th September 2011, 07:42
  4. How to use a file to setup a QProgressDialog, Thanks
    By HelloDan in forum Qt Programming
    Replies: 20
    Last Post: 22nd February 2009, 08:55
  5. How to set paths?
    By hoborg in forum Installation and Deployment
    Replies: 11
    Last Post: 24th February 2006, 20:08

Tags for this Thread

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.