Results 1 to 3 of 3

Thread: Trouble with relative paths for files

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Re: Trouble with relative paths for files

    See QDir and QDir::cdUp

    Basically, you can give QCoreApplication::applicationDirPath() to the constructor of QDir, then perform cdUp function on that object and retrieve new directory. If it's not possible to go further up (eg. if the application is in the root directory), the cdUp method will fail.

  2. #2
    Join Date
    Dec 2009
    Posts
    128
    Platforms
    Unix/X11 Windows
    Thanks
    7
    Thanked 14 Times in 14 Posts

    Default Re: Trouble with relative paths for files

    Also, you could output the result of your string concatenation (or go in debug mode) to be sure of what you're doing.
    My guess is that you missed a "/" after application dir path

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

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.