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

QFileSystemWatcher is not watching changes in folder attributes

    XMLWordPrintable

Details

    • Windows
    • efff8ff57a70f6de9a70e2bfda625bef86a9d6b6 (qt/qtbase/5.14)

    Description

      In the sample below (tested on Windows Server 2016 x64 with VS 2017 x64 and Qt 5.13.2) a root folder is set in order to install a file system watcher on it. The root folder contains another folder in it (initially this folder is not hidden). Start the application: should show the number of items in the root folder. From Windows Explorer change the folder attributes to hidden. This change is not detected by the file system model, but if you restart the application you will notice that the number of items in the root folder is decreased by one (i.e the hidden folder is detected).

      Instead of restarting the application you might try to change the name of the hidden folder (the layout is not changed) or the name of another item (layout is changed and the number of items is shown correctly).

      I would expect that this change in folder attributes to be detected, especially the hidden attribute change since this has an impact on how the items are shown in a Tree view for example.
       

      #include <QDebug>
      #include <QFileSystemModel>
      #include <QGuiApplication>
      int main(int argc, char *argv[])
      {
        QGuiApplication a(argc, argv);
      
        QFileSystemModel model;
        const auto filters =
            (QDir::AllEntries & ~QDir::Hidden) | QDir::NoDotAndDotDot;
        model.setFilter(static_cast<QDir::Filters>(filters));
        const QString path = "E:/projects/temp";
        model.setRootPath(path);
        QObject::connect(
            &model, &QFileSystemModel::layoutChanged,
            [&]() { qInfo() << "layoutChanged" << model.rowCount(model.index(path)); }
        );
        return a.exec();
      }
      

      See also this thread on Qt forums: https://forum.qt.io/topic/109342/qfilesystemmodel-is-not-updating-correctly-when-setting-filter-for-hidden-items/3

      Attachments

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

        Activity

          People

            chehrlic Christian Ehrlicher
            cristeab Bogdan Cristea
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes