Results 1 to 2 of 2

Thread: set path with qmake and use it in the program

  1. #1
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default set path with qmake and use it in the program

    Hello forum,

    I want to declare a custom variable in qmake that contains the absolute path to some files. and later inside the application program i want to use the variable in qmake to get to the path and load the desired file i want to load.


    Is that possible?

    Any more reference example will be very helpful

    Regards
    Sajjad

  2. #2
    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: set path with qmake and use it in the program

    Is that possible?
    Yes.

    Now on to the question you really wanted to ask:
    Qt Code:
    1. // *.pro
    2. DEFINES += SOMEDIR=\\\"/some/full/path/\\\"
    3.  
    4. // *.cpp
    5. QFile file(SOMEDIR "filename.ext");
    6. // or
    7. QDir path(SOMEDIR);
    8. QString filePath = path.filePath("filename.ext");
    To copy to clipboard, switch view to plain text mode 
    Hard coding paths like this is not advisable for anything other than tests IMHO.

Similar Threads

  1. Replies: 6
    Last Post: 5th April 2014, 14:44
  2. qmake and nmake (wrong path to Qt in makefile)
    By StarShaper in forum Installation and Deployment
    Replies: 0
    Last Post: 9th March 2012, 05:23
  3. qmake absolute vs relative LIBS path
    By TheShow in forum Newbie
    Replies: 7
    Last Post: 12th October 2010, 14:40
  4. Where does qmake get the qt path?
    By reimer in forum Installation and Deployment
    Replies: 6
    Last Post: 2nd August 2008, 07:54
  5. Replies: 16
    Last Post: 4th October 2007, 22:04

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.