Results 1 to 2 of 2

Thread: someting wrong with currentPath on linux

  1. #1
    Join Date
    Apr 2012
    Posts
    40
    Platforms
    Unix/X11 Windows

    Default Re: someting wrong with currentPath on linux

    Hi i have problem with currentPath on linux (debian).
    i write simple code:
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QtGui>
    3. #include <QtCore>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8.  
    9.  
    10. QLineEdit line;
    11.  
    12. line.setText(QDir::currentPath()); b
    13.  
    14. line.show();
    15.  
    16. return a.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 

    and now if i build and execute in QtCreator then work, but if i change place binary file then he all time show my home directory (/home/username) . Why ???


    Added after 1 53 minutes:


    i change QDir::currentPath(); to QCoreApplication::applicationDirPath () and work correct
    Last edited by Pablik; 30th April 2012 at 21:17.

  2. #2
    Join Date
    Nov 2008
    Location
    Berlin, Germany
    Posts
    13
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded PyQt3 PyQt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: someting wrong with currentPath on linux

    Quote Originally Posted by Pablik View Post
    Hi i have problem with currentPath on linux (debian).
    i change QDir::currentPath(); to QCoreApplication::applicationDirPath () and work correct
    thats right. QCoreApplication::applicationDirPath () gets you the path where the binary is installed. QDir::currentPath() gets you the current path, not very surprising. I guess you called the binary from your home directory?

Similar Threads

  1. Replies: 5
    Last Post: 25th April 2012, 11:34
  2. Something terribly wrong with static linux builds
    By snookie in forum Qt Programming
    Replies: 0
    Last Post: 8th June 2011, 22:22
  3. difference between source in Qt for X11/Linux Qt for Embedded Linux
    By sanjeet in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 7th June 2011, 02:58
  4. QDir::currentPath() and start program at login - Windows
    By been_1990 in forum Qt Programming
    Replies: 2
    Last Post: 17th February 2010, 01:49
  5. Replies: 10
    Last Post: 7th April 2006, 18:23

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.