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. QFileSystemModel doesn't emit fileRenamed signal

QFileSystemModel doesn't emit fileRenamed signal

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 480 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.
  • Y Offline
    Y Offline
    yeakub
    wrote on last edited by yeakub
    #1

    I am trying to watch the changes in a directory using QFileSystemModel. Whenever I rename a file in the root path, only the directoryLoaded() signal is emitted. I want the fileRenamed() signal to be emitted so that I know which file is renamed to a new name. Here is my code:

        model = new QFileSystemModel;
        model->setRootPath("C:/test/");
        QObject::connect(model, SIGNAL(fileRenamed(const QString&, const QString&, const QString&)), this, SLOT(updateRename()));
        QObject::connect(model, SIGNAL(directoryLoaded(const QString&)), this, SLOT(loadDir()));
    
    JonBJ 1 Reply Last reply
    0
    • Y yeakub

      Yes, correct. I renamed the file manually. I am guessing that the QFileSystemModel only sends the signal if the file is renamed inside the model. But I couldn't find any documentation on that.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #4

      @yeakub said in QFileSystemModel doesn't emit fileRenamed signal:

      QFileSystemModel only sends the signal if the file is renamed inside the model.

      Well, yes, naturally.

      If you are wanting to track external changes you are supposed to use QFileSystemWatcher.

      1 Reply Last reply
      2
      • Y yeakub

        I am trying to watch the changes in a directory using QFileSystemModel. Whenever I rename a file in the root path, only the directoryLoaded() signal is emitted. I want the fileRenamed() signal to be emitted so that I know which file is renamed to a new name. Here is my code:

            model = new QFileSystemModel;
            model->setRootPath("C:/test/");
            QObject::connect(model, SIGNAL(fileRenamed(const QString&, const QString&, const QString&)), this, SLOT(updateRename()));
            QObject::connect(model, SIGNAL(directoryLoaded(const QString&)), this, SLOT(loadDir()));
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @yeakub
        To confirm:

        • You are renaming file C:\test\fileold to C:\test\filenew?
        • You do not get fileRenamed signal?
        • But instead you do get a directoryLoaded signal? Parameter C:/test/?
        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          yeakub
          wrote on last edited by
          #3

          Yes, correct. I renamed the file manually. I am guessing that the QFileSystemModel only sends the signal if the file is renamed inside the model. But I couldn't find any documentation on that.

          JonBJ 1 Reply Last reply
          0
          • Y yeakub

            Yes, correct. I renamed the file manually. I am guessing that the QFileSystemModel only sends the signal if the file is renamed inside the model. But I couldn't find any documentation on that.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #4

            @yeakub said in QFileSystemModel doesn't emit fileRenamed signal:

            QFileSystemModel only sends the signal if the file is renamed inside the model.

            Well, yes, naturally.

            If you are wanting to track external changes you are supposed to use QFileSystemWatcher.

            1 Reply Last reply
            2

            • Login

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