Results 1 to 3 of 3

Thread: QWidget-derived Application Plugins

  1. #1

    Default QWidget-derived Application Plugins

    All-

    I'm building an application that I'd like to have load a set of self-contained modules (compiled as Libraries and loaded through the QPluginLoader framework). Each module inheirits from QWidget and implements a custom interface of my design.

    I've been successful in building such a module and having it loaded (proof-positive in that I can call functions in the library module from the application and get correct values back).

    The plugin examples packaged with Qt provide hints at nearly everything I need to do, except one thing -- these modules contain UI's that need to be drawn, and at present are not.

    The usual process, it seems, is to setup the interface in the constructor, having passed a parent widget to draw upon. In the plugin framework, the constructor is called with the call to QPluginLoader::loader(QString path). This does not seem to provide the means to say 'this is a graphical component -- draw it on this surface".

    So -- after much introduction the question: How do I get a stand-alone QWidget-drived library plugin to draw its' components on a specified surface?

    Thanks for your help!

    SnarlCat

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QWidget-derived Application Plugins

    Instead of making the plugin itself a QWidget, make it allocate and return a QWidget when requested, more or less like this:
    Qt Code:
    1. class MyPluginInterface
    2. {
    3. ...
    4. QWidget* createWidget(QWidget* parent) = 0;
    5. ...
    6. };
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3

    Default Re: QWidget-derived Application Plugins

    With some retooling, it worked!

    Thank you.

    I'd discovered a similar (though more convoluted) way just before reading your post, but your suggestion is, IMO, better than mine...

    Follow-on question:

    These modules are an aggregation of widgets and code, connected through module-private signals and slots. Now that the UI is drawn on a parent object, how I do re-connect these private signals and slots so that the interface is processed properly? I might have thought they would be reconnected as they're part of the same block of code, but they don't seem to be.. Thoughts?

    Thanks!

    SnarlCat

Similar Threads

  1. Replies: 0
    Last Post: 18th February 2008, 10:53
  2. Setting window icon on derived QWidget
    By steg90 in forum Qt Programming
    Replies: 5
    Last Post: 16th July 2007, 11:21
  3. Replies: 1
    Last Post: 2nd May 2006, 21:11
  4. Plugins as small application
    By blackliteon in forum Qt Programming
    Replies: 4
    Last Post: 12th January 2006, 09:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.