Someting wrong with currentPath on linux



  • Hi i have problem with currentPath on linux (debian).
    i write simple code:
    [code]
    #include <QtGui/QApplication>
    #include <QtGui>
    #include <QtCore>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    QLineEdit line;
    
    line.setText(QDir::currentPath()); b
    
    line.show();
    
    return a.exec&#40;&#41;;
    

    }
    [/code]

    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 ???



    1. Create a launcher(xxxxx.desktop) for your application, then set currentPath in this file, and start your application using the launcher.

    2. Create a shell script for your application, set current path evn in the script.

    3. launch your application in a Terminal.

    4. ....


    In addition, do you really want to show currentPath in your LineEdit? or what you want is application's directory?



  • I want show directory to binary file .
    Can you tell me why its work in terminal ??



  • [quote author="Pablik2005" date="1335814726"]I want show directory to binary file .
    Can you tell me why its work in terminal ??[/quote]

    What you need is
    @
    QCoreApplication::applicationDirPath ()
    @

    Current Pah, also known as Current Working Directory, is a basic but important concept.



  • its work thx :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.