[Qt-interest] I don't get the plugin systems documentation
Niklas Berglund
niklas at asdasd.net
Tue Feb 24 00:40:06 CET 2009
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:
Define a set of interfaces (classes with only pure virtual functions)
used to talk to the plugins.
Use the Q_DECLARE_INTERFACE() macro to tell Qt's meta-object system
about the interface.
Use QPluginLoader in the application to load the plugins.
Use qobject_cast() to test whether a plugin implements a given
interface.
Writing a plugin involves these steps:
Declare a plugin class that inherits from QObject and from the
interfaces that the plugin wants to provide.
Use the Q_INTERFACES() macro to tell Qt's meta-object system about the
interfaces.
Export the plugin using the Q_EXPORT_PLUGIN2() macro.
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/a232e77d/attachment.html
More information about the Qt-interest-old
mailing list