[Qt-interest] Using Qt in a shared library
Murphy, Sean M.
sean.murphy at gd-ais.com
Thu May 7 17:11:41 CEST 2009
I'm trying to write a plug-in for a non-Qt application and am having
some event loop issues. The non-Qt application that I'm writing for has
PC and Linux versions, and the plug-in I'm writing performs the same
basic functionality as applications I've already written using Qt, so
I've got all these nice (working) Qt classes ready to go, so I have a
strong desire to write my plug-in using Qt.
To create the plug-in, I inherit from their base plug-in class, and
reimplement 3 virtual functions:
Start()
Callback()
Close()
Start() and Close() are what my plug-in needs to do at load and unload,
and Callback() is called by the application "several times per second"
and it's where I need to do all my updates.
I've got a working version for the PC, but I'm not entirely sure how it
works. I create a new instance of my main class, which inherits from
QDialog, and connect all my signals and slots up (buttons on the dialog,
networking stuff in a QTcpSocket object, etc.), in the Start() function.
Then in Callback() I just call show() on my dialog. Originally I tried
calling exec(), but then the event loop never gets passed back to the
application - so my GUI works perfectly, but the main application is
locked up. ***So in my working version, at no time do I call exec() on
anything*** but yet it works fine on Windows.
So then I tried to build the Linux version of my plug-in. The
application is able to load it fine, but I don't appear to get any
events to fire in the Qt section of my code. If I switch my show() call
to an exec() call, my dialog appears and works correctly, but the main
application is locked up.
At this point I'm kind of stumped. I'm wondering if I have to have my
plug-in spawn off a separate thread from their Start(), and put all the
Qt QApplication and GUI stuff over in that thread, and just populate a
data structure in my Qt slots, and parse the data structure in their
Callback().
Anyone have any similar experience?
Sean
More information about the Qt-interest-old
mailing list