Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-35877

FileDialog can't select read-only file

    XMLWordPrintable

Details

    Description

      main.qml
      import QtQuick 2.0
      import QtQuick.Dialogs 1.0
      
      FileDialog {
         id: dialog
         Component.onCompleted: open()
      }
      

      When I try to open file in read-only mode it shows

      readonly.txt
      This file is set to read-only.
      Try again with a different file name.
      [OK]

      and doesn't accept selection.

      The problem is in /qtdeclarative/src/imports/dialogs/qquickabstractfiledialog.cpp
      Ctor sets m_selectExisting to true but m_options->fileMode() is AnyFile by default. But according QQuickAbstractFileDialog::updateModes() it shoud be ExistingFiles.

      Please add updateModes() call to ctor to fix this issue.

      Workaround.qml
      import QtQuick 2.0
      import QtQuick.Dialogs 1.0
      
      FileDialog {
         id: dialog
         Component.onCompleted: {
             // Blink property to cause updateModes() call
             selectExisting = false;
             selectExisting = true;
             open();
         }
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            srutledg Shawn Rutledge
            setosha Anton Sergunov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes