Qt-interest Archive, March 2002
Re: Loading of Widget Plugins
Message 1 in thread
Hi "Trolls", Hi list!
I got some problems with QWidgetPlugins and at the german "Cebit" a
friend was able to solve the problems while talking to a "troll".
The documentation of the Plugins is not very good. I find a lot of
documentation about "How to write plugins", but I was unable to find a
documentation about "How to use plugins".
Writing a QWidgetPlugin is really easy. Just write the Widget as you
wish and then create a Class derivered from QWidgetPlugin. You can use a
Key, that must me unique. (So I like to use something with a domain in
front. "de.neitzel.my-plugin")
After you build the Plugin you get the lib* files. These Files must be
placed in the "$QT/plugins/designer" or "somepath/designer" directory!
(The "designer" at the end is really important!!!)
Using the Plugin (It's really easy):
A really small example is (main.cpp!):
QApplication a( argc, argv );
/* Setting an additional Path: ~/plugins/designer */
a.addLibraryPath("~/plugins");
/* New QWidgetFactory and loading the Widget with the name
"de.neitzel.TestMod */
QWidgetFactory wf;
QWidget *nw = wf.createWidget("de.neitzel.TestMod", NULL, NULL);
if (nw != NULL) {
nw->show();
} else {
cout << "Unable to load Plugin!\n";
exit(1);
}
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
Maybe the Trolls will add some more stuff to the Documentation about
this fact!
With kind regards,
Konrad Neitzel
--
[ signature omitted ]