View Full Version : Custom Widget Collection

24th October 2009, 17:39

I created individual custom widget successfully. Now I wanna combine them into one lib. For example:

+ Dog-house (custom widget 1) with a class named Kiki--> dog.dll
+ Cat-house (custom widget 2) with a class named Kitty --> cat.dll

Now I wanna put them into Animal (custom widget) --> animal.dll

Method1: include source code of 2 classes above in the animal project (separate files or in one file). Built successfully. Loaded in Designer. But can't build in testing project. Error is:

release/dialog.o:dialog.cpp::-1: error: undefined reference to `Kiki::Kiki(QWidget*)'

although I did add "LIBS += animal.dll".

Method2: make use of above dlls (not include classes in source code). I have to make new dlls where they don't have Q_EXPORT_PLUGIN2. But the output dll (animal.dll) - can't be loaded in Designer.

For each method, could you please tell me how to solve the problem? In fact I prefer the second, but I don't know if it's possible.

Thank you in advance :-)

24th October 2009, 19:38
first lets make some order in the terminology, to make sure we are all speaking the same language.
First, what exactly do you mean when you say "put in"?
Second, custom widgets may be based, contain and integrate more than one class.
A shared lib, or a DLL, can contain any number of classes too.
Its a bit different for designer plugins, in the sense that it is not always desired, from usability perspective, to have more then one custom widget in one designer plugin.
So if you have several custom widgets that you would like to have in designer as plugin, I would suggest you put each custom widget (which is not the same as a class!) in one designer plugin.
In other words, all classes that are needed for one custom widget in one designer plugin.

If it is not a designer plugin you want, you can pack all the classes/widgets in one lib.

To your linking problem:
"LIBS += animal.dll" is wrong.
A dll is an executable, or, its a run time lib.
Your application will link to it once it is running.
But you need to tell the linker, at build time, where the symbols are that you are using from that lib.
For that you should use:
"LIBS += -lanimal" - and make sure you have anilmal.lib (not DLL!) in your lib path.

25th October 2009, 01:38
Hi High_flyer,

Sorry for the bad English which is not my mother tongue. I'll be careful with phrasal verb. I meant "combine several custom widgets into a single library."

Yes, I know about plugin and custom widget classes. Typically, a designer plugin which has 1 or more custom widgets. Each custom widget has an interface and a working class. Is it right?

Now I'm confused because I can't repeat the LIBS += kitty.dll. I ever did that to test customwidgetplugin.dll (with AnalogClock) in examples\designer\worldtimeclockplugin\. In theory, that's right that we must have a lib file to make the compilation successful. The dll will be used at runtime. But the output of building a custom widget is only .dll and .a. Now I don't know how to run a single custom widget any more!!! What is the different between customwidgetplugin.dll and my kitty.dll?
Maybe I have to solve this problem before advancing to multi custom widgets per plugin.
Could you help me again? Thanks so much.

25th October 2009, 02:41
OK, I found it! I forgot to export the class (working class). Now I can run single and multi widget plugin!

Thanks anyway. Have a nice day!