Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Anyone using Qt inside their own SDK?
chopper last edited by
I'm looking to make use of some of Qt's cross platform network capabilities (which I've always enjoyed) - and I was curious as to how this would affect client applications that planned to use my SDK - because I suspect that large swathes of Qt will not function properly without a QApplication instance someplace...
I wouldn't sweat my SDK instancing one except my concern is that a client application may itself be a Qt application - I suspect this is likely a serious problem. I assume there are many singletons at that level.
Can you use, safely, a QCoreApplication if you isolate it to its own thread (at least avoiding event loop blocking)?
Can you run the networking subsystem off a local event loop?
Can you use a static request for the active QCoreApplication object and if not found, just use one during the scope of your operation? (Risky as it could be a race condition depending upon the behavior of the client application...)
In my limited experience, it was enough if the calling application that used my DLL was running an event loop - be it QCoreApplication or QGuiApplication. If none of these were available, I started my own QCoreApplication.
Luckily, QCoreApplication::instance() returns nullptr if none of these exist so you can spin of your own loop.
More interesting would be, if your SDK and the calling app uses different Qt versions. For that, Qt in namespace might be worth reading.
Others may add more points - for my simple DLL (using Qt Network, SerialPort and soon SerialBus) that was enough so far.