Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QFileSystemWatcher not working



  • This post is deleted!

  • Lifetime Qt Champion

    Hi,

    If you want implementation details, just read Qt's source code.

    Your while loop just infinitely creates new connections.

    You need a QApplication/QGuiApplication for things to work correctly.

    Form the looks of it, you might be over-engineering stuff.

    I would recommend starting with the Qt documentation about C++ integration with QtQuick. Once you have that sorted out. Come back to your json file watcher.

    Write a simple wrapper class that contains the watcher and does the file reloading.



  • Your code shows a lot of ignorance of how Qt works, as they point out, I recommend you read the docs urgently. Here no thread is necessary, it is only necessary to use the Qt event loop. Forget about sequential programming (Qt hates while true since they are not needed). You also do not know what the Qt signals are and how they are used.

    Also you do not understand the advantages and restrictions of threads, it is not safe to access and modify variables in different threads as you try to do.



  • This post is deleted!


  • This post is deleted!