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

[SOLVED] QSocketNotifier: Can only be used with threads started with QThread



  • My application is coded with qt4
    i added this to the .pro file @QT += widgets@

    to remove the #include errors on qt5.

    Now i have this warning:
    @Starting /home/citybong/Downloads/build-wallch-Desktop-Debug/wallch...
    QSocketNotifier: Can only be used with threads started with QThread
    QSocketNotifier: Can only be used with threads started with QThread@

    which i don't know what it is, what causes it, and how to fix it.



  • I am trying to build a project here which doesn't even use the QSocketNotifier library.

    What?


  • Lifetime Qt Champion

    But internally it might be used.

    That question might find better answer on the mailing list (you'll find Qt's developers/maintainers there, this forum is more user oriented)



  • If it is internally used (by some other library) and that causes the problem, then I don't have control over it! Why does it complain to me?


  • Moderators

    [quote author="alexandros" date="1375132190"]If it is internally used (by some other library) and that causes the problem, then I don't have control over it! Why does it complain to me?[/quote]Because it needs you to use your classes differently.



  • Hi, normally, the error will occur when you access a non-thread-safe object which is created in another thread, in other words, wrong usage of QThread will cause this problem.



  • Well apparently it had something to do with QFileSystemWatcher
    Fixed ;)



  • @Leon said in [SOLVED] QSocketNotifier: Can only be used with threads started with QThread:

    Well apparently it had something to do with QFileSystemWatcher
    Fixed ;)

    Leon didn't say what it had to do with the QFileSystemWatcher. For future googlers out there, what worked for me was to make sure the QThread had called its start() function first before utilizing the FileSystemWatcher's signals and slots, i.e. don't do it in the construction.

    Not sure if that'l work for everyone but it fixed my problem.


Log in to reply