[Qt-interest] Could I use a QObject based class to create Qt Plugin?

Jaco Naude naude.jaco at gmail.com
Wed Oct 13 08:54:08 CEST 2010


I normally use a method which has been discussed on this list in the
past. I create an abstract interface from which all my other
interfaces inherit (using virtual inheritance).

Here is an example of this interface:
http://www.qtilities.org/docs_v0_2/src_2_core_2source_2_i_object_base_8h_source.html

Here is an example of a plugin interface which implements the above interface:
http://www.qtilities.org/docs_v0_2/src_2_extension_system_2source_2_i_plugin_8h_source.html

Here is an example of a plugin which uses the interface:
http://www.qtilities.org/docs_v0_2/_project_management_plugin_8h_source.html

If you would then want to make any of the methods on your plugin
interface implementation slots your declare them as slots in your
implementation class. You also declare any other signals and/or slot
you want to use in the implementation class.

It is then possible to do something like this on your interface reference:
IPlugin* pluginIFace = a_reference_to_your_plugin;
connect(pluginIFace->objectBase(),SIGNAL(yourSignal()),SLOT(yourSlot()));
or
connect(this,SIGNAL(yourSignal()),pluginIFace->objectBase(),SLOT(yourSlot()));

There are probably different ways to do this but this works very well for me.
Hope it helps.




2010/10/13 danny <tornadory at 163.com>:
> Hi all,
>
> From
> http://doc.qt.nokia.com/4.6/plugins-howto.html#the-lower-level-api-extending-qt-applications,
> I saw the methods to create a Qt Plugin, and from the example I saw that the
> Interface Class should be a virtual Class , so it could not inherit from
> QObject, is it right?
>
> If I want the Plugins have its signal/slot, how could I do?  I want to use
> the interface class object and connect some signals from/to it.
>
> Any ideas to help me?
>
> Thanks in advance.
>
>
> --
>  Best Regards,
>
>
>
> ________________________________
> 全国最低价,天天在家冲照片,24小时发货上门!
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>




More information about the Qt-interest-old mailing list