QEventLoop: Cannot be used without QApplication. Error in a multi-threaded library
I'm making a library which contains a QThread object. I am going with the moveToThread style.
The DLL is successfully loaded but Qt Creator's application output gives QEventLoop: Cannot be used without QApplication.
I've done some searching work and it suggests I need a QApplication. I don't have a main() in the library so I have no idea where I can put the QApplication object.
Thanks in advance.
Re: QEventLoop: Cannot be used without QApplication. Error in a multi-threaded librar
The library itself should not instantiate QApplication, but every program loading it should.
Re: QEventLoop: Cannot be used without QApplication. Error in a multi-threaded librar
Quote:
Originally Posted by
yeye_olive
The library itself should not instantiate QApplication, but every program loading it should.
Yes I think so. But it just gives this error. My loader is a normal Qt GUI which already has QApplication.
Oh what if the load is not a Qt program which does not have any QApplication?
Re: QEventLoop: Cannot be used without QApplication. Error in a multi-threaded librar
Quote:
Originally Posted by
hind
But it just gives this error. My loader is a normal Qt GUI which already has QApplication.
You probably get this error because some QEventLoop is allocated by the library before the QApplication instance by the program. Does your library have a global variable (or static member field) of a QObject-derived type?
Quote:
Originally Posted by
hind
Oh what if the load is not a Qt program which does not have any QApplication?
Then you should not use QThread (and more generally QObjects) in your library as it depends on Qt's event loop for signal delivery.
Re: QEventLoop: Cannot be used without QApplication. Error in a multi-threaded librar
Quote:
Originally Posted by
yeye_olive
You probably get this error because some QEventLoop is allocated by the library before the QApplication instance by the program. Does your library have a global variable (or static member field) of a QObject-derived type?
Then you should not use QThread (and more generally QObjects) in your library as it depends on Qt's event loop for signal delivery.
Thank you for your replies. But when I accidentally swithed the loader from debug to release, the problem is gone...
And thanks for the second answer.