[Qt-interest] I don't get the plugin systems documentation

Bruno Colombet Bruno.Colombet at univmed.fr
Tue Feb 24 10:42:52 CET 2009


Hello, 

Are you sure that the interface inheritance is public? (did not see class
myplugin : public Interface).

 

B.

 

 

De : qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] De la part de Niklas Berglund
Envoyé : mardi 24 février 2009 00:40
À : qt-interest at trolltech.com
Objet : [Qt-interest] I don't get the plugin systems documentation

 

Hello

I'm trying to implement dynamic loading of plugins. But I ran into trouble.

The plugin compiles, but I cannot load it.

When loading I get an error string saying it is not a compatible Qt plugin.

 

I've been reading http://doc.trolltech.com/4.3/plugins-howto.html over and
over(section "The Lower-Level API: Extending Qt Applications"), but I don't
get what's wrong!

Been taking a look at the examples echo server and plug and paint too.

 

I am confused about the checklist:

            Making an application extensible through plugins involves the
following steps:

1.	Define a set of interfaces (classes with only pure virtual
functions) used to talk to the plugins.
2.	Use the
<http://doc.trolltech.com/4.3/qtplugin.html#Q_DECLARE_INTERFACE>
Q_DECLARE_INTERFACE() macro to tell Qt's
<http://doc.trolltech.com/4.3/metaobjects.html> meta-object system about the
interface.
3.	Use  <http://doc.trolltech.com/4.3/qpluginloader.html> QPluginLoader
in the application to load the plugins.
4.	Use  <http://doc.trolltech.com/4.3/qobject.html#qobject_cast>
qobject_cast() to test whether a plugin implements a given interface.

            Writing a plugin involves these steps:

1.	Declare a plugin class that inherits from
<http://doc.trolltech.com/4.3/qobject.html> QObject and from the interfaces
that the plugin wants to provide.
2.	Use the  <http://doc.trolltech.com/4.3/qobject.html#Q_INTERFACES>
Q_INTERFACES() macro to tell Qt's
<http://doc.trolltech.com/4.3/metaobjects.html> meta-object system about the
interfaces.
3.	Export the plugin using the
<http://doc.trolltech.com/4.3/qtplugin.html#Q_EXPORT_PLUGIN2>
Q_EXPORT_PLUGIN2() macro.
4.	Build the plugin using an suitable .pro file.

Under "Writing a plugin involves these steps" I'm wondering about the 3rd
point. This is not used in the example code a few lines down.

Anyways I tried using it. I include <QtPlugin> and then use it in my plugin
implementation.

 

I did a small example with my problem:

PluginInterface.h
http://pastebin.com/m570b0214

PluginExample.h                               http://pastebin.com/m76fa2ca6

PluginExample.cpp           http://pastebin.com/m699b7259

My .pro-file
http://pastebin.com/m4bac5157

 

There probably is something I'm missing but I still get the feeling the
documentation is wrong here? There's a semicolon missing after
Q_DECLARE_INTERFACE in the interface example, and if you check out the
documentation for 4.5 that line is missing completely even though it seems
its still necessary to use in 4.5?

 

I'm using Qt 4.3 on Mac OS X.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090224/4215d799/attachment.html 


More information about the Qt-interest-old mailing list