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. QFileDialog returns wrong path
Forum Updated to NodeBB v4.3 + New Features

QFileDialog returns wrong path

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 1.4k Views
  • 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.
  • Q Offline
    Q Offline
    Qingshui Kong
    wrote on 11 Oct 2018, 01:58 last edited by
    #1

    Hello,

    Could somebody help me?

    Recently, I am learning QT. I want to use QFileDialog to open some file. But I don't want to use native dialog, so I set QFileOption::DontUseNativeDialog to true. It works, and I can see QT own QFileDialog.

    But there is a problem. If I use native dialog, it will select the first item by default when I enter a folder. But QT own QFileDialog doesn't act the same. Exactly, it works wrong.
    Here is the detail.
    When I open a QFileDialog, it select nothing, and the open button is disabled.
    0_1539222112351_cf71592c-ee66-47fc-a2f7-e90605dd7ba7-image.png

    Then I select a file manully, and the open button is enabled.
    0_1539222256279_ec48c082-de59-4b70-89d0-6360f7832d23-image.png

    Then I enter another folder, but it selects nothing in the folder. What's more the open button is still enabled.
    0_1539222448322_82fad506-2410-4d91-85e8-5c93100a1ccf-image.png

    Finally, I click the open button, and I get a file returned. But its path is not correctly. Its path is /tmp/VMwareDnD/config-err-2Emdj0. But the right path should be /tmp/config-err-2Emdj0
    0_1539222965601_3bede7d3-5d68-4e57-a461-1c4f6c9a5dfa-image.png

    What should I do to solve this problem?

    My environment.
    ubuntu 16.04
    0_1539223029901_83814b4c-e91b-4b83-afff-b15394edc347-image.png
    0_1539223058094_42e92609-1280-45b2-862f-06add43df7f3-image.png

    Thanks.

    J 1 Reply Last reply 11 Oct 2018, 04:20
    0
    • Q Qingshui Kong
      11 Oct 2018, 01:58

      Hello,

      Could somebody help me?

      Recently, I am learning QT. I want to use QFileDialog to open some file. But I don't want to use native dialog, so I set QFileOption::DontUseNativeDialog to true. It works, and I can see QT own QFileDialog.

      But there is a problem. If I use native dialog, it will select the first item by default when I enter a folder. But QT own QFileDialog doesn't act the same. Exactly, it works wrong.
      Here is the detail.
      When I open a QFileDialog, it select nothing, and the open button is disabled.
      0_1539222112351_cf71592c-ee66-47fc-a2f7-e90605dd7ba7-image.png

      Then I select a file manully, and the open button is enabled.
      0_1539222256279_ec48c082-de59-4b70-89d0-6360f7832d23-image.png

      Then I enter another folder, but it selects nothing in the folder. What's more the open button is still enabled.
      0_1539222448322_82fad506-2410-4d91-85e8-5c93100a1ccf-image.png

      Finally, I click the open button, and I get a file returned. But its path is not correctly. Its path is /tmp/VMwareDnD/config-err-2Emdj0. But the right path should be /tmp/config-err-2Emdj0
      0_1539222965601_3bede7d3-5d68-4e57-a461-1c4f6c9a5dfa-image.png

      What should I do to solve this problem?

      My environment.
      ubuntu 16.04
      0_1539223029901_83814b4c-e91b-4b83-afff-b15394edc347-image.png
      0_1539223058094_42e92609-1280-45b2-862f-06add43df7f3-image.png

      Thanks.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 11 Oct 2018, 04:20 last edited by
      #2

      @Qingshui-Kong Did you check in Qt bug tracker whether this is a known issue? If it is not you can file a bug.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      Q 1 Reply Last reply 11 Oct 2018, 07:02
      0
      • J jsulm
        11 Oct 2018, 04:20

        @Qingshui-Kong Did you check in Qt bug tracker whether this is a known issue? If it is not you can file a bug.

        Q Offline
        Q Offline
        Qingshui Kong
        wrote on 11 Oct 2018, 07:02 last edited by Qingshui Kong 10 Nov 2018, 07:18
        #3

        @jsulm
        Thanks.

        I find a similar bug https://bugreports.qt.io/browse/QTBUG-2947. It was closed. But it was not soveld completely.

        J 1 Reply Last reply 11 Oct 2018, 07:09
        0
        • Q Qingshui Kong
          11 Oct 2018, 07:02

          @jsulm
          Thanks.

          I find a similar bug https://bugreports.qt.io/browse/QTBUG-2947. It was closed. But it was not soveld completely.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 11 Oct 2018, 07:09 last edited by
          #4

          @Qingshui-Kong It isn't solved at all:
          "Resolution: Out of scope"
          "Fix Version/s: Some future release"

          I don't know why it is considered as "Out of scope".
          Nobody voted for it. Maybe you can try to reopen it or file a new one.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          Q 1 Reply Last reply 11 Oct 2018, 07:15
          0
          • J jsulm
            11 Oct 2018, 07:09

            @Qingshui-Kong It isn't solved at all:
            "Resolution: Out of scope"
            "Fix Version/s: Some future release"

            I don't know why it is considered as "Out of scope".
            Nobody voted for it. Maybe you can try to reopen it or file a new one.

            Q Offline
            Q Offline
            Qingshui Kong
            wrote on 11 Oct 2018, 07:15 last edited by
            #5

            @jsulm

            Yes. It isn't solved. But something must have changed. Because in my software the open button will be disabled, if I delete the file name.

            Maybe, the reason is that it is a suggestion. But I think it is a bug!

            J 1 Reply Last reply 11 Oct 2018, 07:18
            0
            • Q Qingshui Kong
              11 Oct 2018, 07:15

              @jsulm

              Yes. It isn't solved. But something must have changed. Because in my software the open button will be disabled, if I delete the file name.

              Maybe, the reason is that it is a suggestion. But I think it is a bug!

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 11 Oct 2018, 07:18 last edited by
              #6

              @Qingshui-Kong Isn't this exactly your problem:
              "1) While browsing across different directories, if you select a file and
              move to another directory, that file name does not get cleared from
              'File name' text box.".

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              Q 1 Reply Last reply 11 Oct 2018, 07:20
              0
              • J jsulm
                11 Oct 2018, 07:18

                @Qingshui-Kong Isn't this exactly your problem:
                "1) While browsing across different directories, if you select a file and
                move to another directory, that file name does not get cleared from
                'File name' text box.".

                Q Offline
                Q Offline
                Qingshui Kong
                wrote on 11 Oct 2018, 07:20 last edited by
                #7

                @jsulm

                Yes, it is.

                You can see that from the picture I attached.

                J 1 Reply Last reply 12 Oct 2018, 02:42
                0
                • Q Qingshui Kong
                  11 Oct 2018, 07:20

                  @jsulm

                  Yes, it is.

                  You can see that from the picture I attached.

                  J Online
                  J Online
                  JonB
                  wrote on 12 Oct 2018, 02:42 last edited by JonB 10 Dec 2018, 02:43
                  #8

                  @Qingshui-Kong
                  The bug was reported in 2008 but never addressed, it seems. You could re-open the issue.

                  You cannot affect the path it returns in this situation. The one it returns is "correct" in the sense of what the final screenshot shows, but that's not really the point.

                  What I suspect you really need to address is: it is possible for the dialog to return a file path which does not exist for a number of reasons, your code must handle the possibility.

                  Q 1 Reply Last reply 12 Oct 2018, 05:28
                  0
                  • J JonB
                    12 Oct 2018, 02:42

                    @Qingshui-Kong
                    The bug was reported in 2008 but never addressed, it seems. You could re-open the issue.

                    You cannot affect the path it returns in this situation. The one it returns is "correct" in the sense of what the final screenshot shows, but that's not really the point.

                    What I suspect you really need to address is: it is possible for the dialog to return a file path which does not exist for a number of reasons, your code must handle the possibility.

                    Q Offline
                    Q Offline
                    Qingshui Kong
                    wrote on 12 Oct 2018, 05:28 last edited by Qingshui Kong 10 Dec 2018, 05:28
                    #9

                    @JonB

                    Thanks! Yes, the bug was reported before but never addressed. I reported a new bug.

                    I solved it by disabling the open button and clearing the lineedit in my slot for the currentChanged signal.

                    But I think there are some other bugs about the DontUseNativeDialog QFileDialog.

                    1 Reply Last reply
                    0

                    8/9

                    12 Oct 2018, 02:42

                    • Login

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