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. Home path is translated into /run/user/1000
Forum Updated to NodeBB v4.3 + New Features

Home path is translated into /run/user/1000

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 1.4k Views 2 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.
  • D Offline
    D Offline
    deleted372
    wrote on last edited by
    #1

    I have snapped a Qt application, when the user wants to open a file I use the QFileDialog::getOpenFileName.
    The path returned is /run/user/1000/doc/39face4d/myFile.txt instead of /home/user/Documents/myFile.txt

    How do I get the “User friendly” path? Is there any configuration I'm missing?

    JonBJ Pl45m4P 2 Replies Last reply
    0
    • D deleted372

      I have snapped a Qt application, when the user wants to open a file I use the QFileDialog::getOpenFileName.
      The path returned is /run/user/1000/doc/39face4d/myFile.txt instead of /home/user/Documents/myFile.txt

      How do I get the “User friendly” path? Is there any configuration I'm missing?

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @JoZCaVaLLo
      /run/user/... is taken from your XDG_RUNTIME_DIR environment variable. It's intended to be just a safe, temporary area you can write to.

      I don't think there is any relationship between the path you mention and the user's actual home directory (e.g. no soft link). So why is the end user choosing to store stuff there from your QFileDialog::getOpenFileName? If you are saying that it starts out from /run/user/1000/doc/39face4d instead of /home/user/Documents or similar, and that is why the user saves there, then please say so?

      1 Reply Last reply
      0
      • D deleted372

        I have snapped a Qt application, when the user wants to open a file I use the QFileDialog::getOpenFileName.
        The path returned is /run/user/1000/doc/39face4d/myFile.txt instead of /home/user/Documents/myFile.txt

        How do I get the “User friendly” path? Is there any configuration I'm missing?

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #3

        @JoZCaVaLLo

        How do you save that file? Does it exist in your directory before or did you create it on runtime? In the second case, I would think about the way, how (and especially where!) the file is saved.

        To make sure, that it's the same directory on every system, you can use this:
        https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

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

          Thank you all for answering...
          The problem is much more snap related... but maybe someone on this forum already found a solution:

          QString fileName = QFileDialog::getOpenFileName( this, QString(), "~", "*.*");
          

          This opens the Choose File Dialog...
          I select the file /home/user/Documents/myFile.txt (already exists).

          The value of fileName is "/run/user/1000/doc/6cdffe5/myFile.txt"
          instead of "/home/user/Documents/myFile.txt"

          JonBJ 1 Reply Last reply
          0
          • D deleted372

            Thank you all for answering...
            The problem is much more snap related... but maybe someone on this forum already found a solution:

            QString fileName = QFileDialog::getOpenFileName( this, QString(), "~", "*.*");
            

            This opens the Choose File Dialog...
            I select the file /home/user/Documents/myFile.txt (already exists).

            The value of fileName is "/run/user/1000/doc/6cdffe5/myFile.txt"
            instead of "/home/user/Documents/myFile.txt"

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by JonB
            #5

            @JoZCaVaLLo said in Home path is translated into /run/user/1000:
            OK, so with that "~" (I would not have used that) it deffo opens correctly in /home/user? Then you browse down from there into Documents and pick something there? Yet it returns a path in /run/user/1000/doc/6cdffe5? Right?

            Sounds odd. I installed stuff once with snap and regretted it and backed out!

            One thought: just make sure the file you're picking is not a soft link into the /run/user area? ls -l /home/user/Documents/myFile.txt before you open it, please. Or, make sure /home/user/Documents hasn't been set up as some soft link to /run/user/1000/doc/...!?

            1 Reply Last reply
            1
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              You are mentioning snap. You might want to give more details about how you are running your application because that's the kind of details that's pretty important to get help properly.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • D Offline
                D Offline
                deleted372
                wrote on last edited by
                #7

                What I do in my snap is to dump the procompiled libs from Qt 5.14.
                But probably I am forgetting to pull a necessary but not required lib or maybe precompiled Qt libs are not totally compatible with snapcraft.

                if I snap my app in the “traditional way”, using the qmake plugin and the qt 5.9 libs that comes with snap, everything works fine...

                Finally, my question is: how do I create a snap for a Qt 5.14.1 application the right way??? Do you know of any example or tutorial?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  You might want to check the linuxdeployqt project.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  D 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    You might want to check the linuxdeployqt project.

                    D Offline
                    D Offline
                    deleted372
                    wrote on last edited by
                    #9

                    @SGaist Snapcraft and appImage are not exactly the same thing.

                    Anyway, if someone else is trying to "snap" a Qt app using a different version then the old ones coming with snapcraft, I created a small project where you may find an hint:
                    https://github.com/jdelromano/snapqt5

                    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