filewatcher.cpp 530 B

123456789101112131415161718192021222324
  1. #include "filewatcher.h"
  2. FileWatcher::FileWatcher()
  3. {
  4. m_fileSystemWatcher = new QFileSystemWatcher(this);
  5. connect(m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, [=](const QString& path)
  6. {
  7. emit sig_dirStateChange(path);
  8. });
  9. };
  10. bool FileWatcher::addPath(const QString& file)
  11. {
  12. return m_fileSystemWatcher->addPath(file);
  13. }
  14. FileWatcher::~FileWatcher()
  15. {
  16. if (m_fileSystemWatcher) {
  17. delete m_fileSystemWatcher;
  18. m_fileSystemWatcher = Q_NULLPTR;
  19. }
  20. };