[Qt-interest] Doubts about the Plugin Framework
Justin Noel
justin at ics.com
Tue Mar 16 15:50:44 CET 2010
Bruno Seabra Lima wrote:
> First of all i wanna apologize for my terrible english. That been
> said, let's focus to the problem.
>
> I've been searching around and found out that u cant use signal/slot
> in a Plugin interface that can be used with the qt plugin mechanism.
> First let me resume the scenario:
> 1 - Im creating a editor to a language, but i wanna my editor to be
> able to be extended via plugins.
> 2 - Those plugins will add a new perspective over the document.
> 3 - So for each new document created i'll need a new instance of the plugin.
> 4 - The new document is going to be attached to the new plugin instance.
>
> Since the "limitations" in the QTPlugin mechanism i am modeling the
> problem in this way:
>
> 1 - I'm defining the interface as a factory to the real object that
> handles the signals/slots i need.
> But my question is:
> I dont recall but i remember to read someplace that the QT Plugin can
> only provide one instance of the interface.
> Is this really true ? or am i mistaken ?
>
The usual solution for this problem is to make your plugin interface
class a factory that creates the real application plugin class.
EditorPlugin* MyEditorPluginFactory::createPlugin()
{
return new MyEditorPlugin(); //Has signals and slots.
}
For this solution to work your app and your plugin must link against a
common library that defines EditorPlugin.
> 2 - The signals emitted by the plugin are been connected to slots in a
> Thread inside my application.
> The question in this case is:
> The thread must run the exec() call to receive those signals, right ?
> I'll have to make a quequed connection of this objects, right
Objects that want to receive cross-thread signals must be running in a
thread that calls exec(). This is because the signals are marshalled
through the threads event loop. No loop, no marshalling.
Good Luck,
--Justin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: justin.vcf
Type: text/x-vcard
Size: 243 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100316/f0d20794/attachment.vcf
More information about the Qt-interest-old
mailing list