Results 1 to 3 of 3

Thread: Having Troubles with QDir and the absolutePath

  1. #1
    Join Date
    Sep 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Having Troubles with QDir and the absolutePath

    Hi everyone
    I am having this small problem.
    I have a folder name IMPORTANT, this folder is located on the main project folder(where the source code is located).

    In this folder, I have a file that I have to open on the application I am doing, here it comes my problem.

    I use QDir, and give the path where the File is located
    Qt Code:
    1. QDir dir("/home/diego/Projects/code/IMPORTANT");
    To copy to clipboard, switch view to plain text mode 
    and the rest of code.

    This works perfect. But here is my problem, what happens if I want to give this code to one friend of my, it will not run on his computer because he doesn't have this address /home/diego/Projects/

    So what I can do to solve this problem?
    Can someone give me an idea?
    Thanks

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Having Troubles with QDir and the absolutePath

    You could use the application directory to store that file. You can find it with:
    QCoreApplication::applicationDirPath ()

    Or use the users homedir:
    QDir::homeDirPath ()

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Having Troubles with QDir and the absolutePath

    Or something relative to any of those.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. FFMPEG Troubles
    By khrave in forum Qt Programming
    Replies: 0
    Last Post: 23rd June 2010, 00:15
  2. troubles with QPainter
    By halmassi in forum Newbie
    Replies: 1
    Last Post: 14th February 2010, 13:12
  3. QSslSocket : Having troubles
    By Nyphel in forum Newbie
    Replies: 3
    Last Post: 27th June 2007, 14:17
  4. makefile troubles
    By Walsi in forum Qt Programming
    Replies: 6
    Last Post: 12th April 2007, 15:12
  5. lupdate *.pro troubles
    By jeff_s in forum Qt Programming
    Replies: 1
    Last Post: 28th July 2006, 10:07

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.