Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Someting wrong with currentPath on linux
Forum Updated to NodeBB v4.3 + New Features

Someting wrong with currentPath on linux

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pablik2005
    wrote on last edited by
    #1

    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 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2
      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?

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Pablik2005
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dbzhang800
          wrote on last edited by
          #4

          [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.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Pablik2005
            wrote on last edited by
            #5

            its work thx :)

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved