Qt World Summit: Register Today!

API Development - QEventLoop: Cannot be used without QApplication

  • We developed an API in Qt, and it worked beautifully when called from another Qt application. However, whenever I tried use the API by calling it from a C# application I ran into some troubles. I noticed the API functions that used helper threads were not working when I called them from the C# application. Whenever I started debugging this on the API side I realized the following error was occurring "QEventLoop: Cannot be used without QApplication". This error occurs for each helper thread that the API spawns with the end result being the threads don't appear to be doing anything.

    I did some research on this and I realize the problem being that QEventLoop needs to be called from an instance of QApplication which in my limited QT experience resides in main.cpp.

    So with all that being said, I am left with the impression that the API in its current state is only going to be compatible with QT applications, and if I needed it to be compatible with anything else we are going to have reimplement the threading on the API side.

    Is my conclusion correct? Does anyone have any suggestions and/or workarounds for this issue?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You would to do something like described "here":http://stackoverflow.com/questions/2150488/using-a-qt-based-dll-in-a-non-qt-application

    Hope it helps

Log in to reply