Qt app in a shared library?
Apologies if this has been asked and answered before, but I sure as heck can't find it.
I've got an app written in Qt that I'm trying to convert to a shared library that can be used in multiple host applications - some Qt, some not. The library must be able to pop up its own Qt windows and everything. I'm having a devil of a time getting even a simple test app to work. I can dynamically load functions from the .so and those work, but if I try and pop up a QWindow it immediately segfaults.
Anybody done this? What do I have to do to make it work? Thanks!
Here's the .pro, by the way:
TEMPLATE = lib
CONFIG += dll
QMAKE_CXXFLAGS += -fPIC -std=c++0x
HEADERS = ParamWindow.h
SOURCES = ParamWindow.cpp
QT += opengl
I haven't done exactly that, but I have experience with mixing Qt and other UI frameworks. Can you post a full small test which demonstrates what you are trying to do? I'm curious, but the devil is usually in the details.
If you want to show QtWidgets, you need an QApplication instance. If you use your library within a QtApp, you have it, if not, there is a problem.
You can write some code inside your dll to check, whether a QApp instance iexists, but if you create it, make sure you also delete it in the end.
How did you integrate QApplication and its event loop in your test?
If you use modal windows, you don't need the QApp event loop, if you use non modal windows, it could be a problem, yes...