December 7, 2010

mistermost mistermost
Lab Rat
1 posts

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

4 replies

December 7, 2010

Bradley Bradley
Lab Rat
300 posts

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.

 Signature 

Nokia Certified Qt Specialist.

December 7, 2010

Gerolf Gerolf
Hobby Entomologist
3251 posts

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.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

December 7, 2010

Frank Frank
Lab Rat
17 posts

How did you integrate QApplication and its event loop in your test?

December 7, 2010

Gerolf Gerolf
Hobby Entomologist
3251 posts

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…

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

 
  ‹‹ [SOLVED] QTextDocument::toHtml("utf-8") and Arabic on Windows      Disable scrolling in QGraphicsView ››

You must log in to post a reply. Not a member yet? Register here!