Results 1 to 3 of 3

Thread: Trouble with relative paths for files

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2009
    Location
    United States
    Posts
    45
    Thanks
    20
    Qt products
    Qt4
    Platforms
    Windows

    Default Trouble with relative paths for files

    I have a lot of things like QIcons that I need to specify a path->filename for, but I don't want to do an absolute path because the project's directory will not always be constant.

    I discovered the QCoreApplication::applicationDirPath() function, which gives the path to the executable file, but my images are a directory above. How can I move up a level? I tried stuff like:

    Qt Code:
    1. QString temp = QCoreApplication::applicationDirPath() + "../icon.png";
    2. setWindowIcon( QIcon(temp) );
    To copy to clipboard, switch view to plain text mode 

    But I haven't had any luck so far.

    Is there an easy way to use relative paths for files?
    Last edited by N3wb; 29th December 2010 at 23:30.

Similar Threads

  1. Trouble Connecting to Microsoft Access *.accdb files
    By FuNkDaDdY in forum Qt Programming
    Replies: 1
    Last Post: 10th November 2010, 10:18
  2. Relative paths in Qt
    By drmath in forum Qt Programming
    Replies: 2
    Last Post: 30th June 2010, 16:50
  3. X11 include and lib paths
    By Oluwafemi in forum Installation and Deployment
    Replies: 1
    Last Post: 3rd April 2010, 15:25
  4. Problems with paths
    By zorro68 in forum Installation and Deployment
    Replies: 1
    Last Post: 13th July 2008, 11:20
  5. How to set paths?
    By hoborg in forum Installation and Deployment
    Replies: 11
    Last Post: 24th February 2006, 19:08

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
  •  
Qt is a trademark of The Qt Company.