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 -
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.