Results 1 to 4 of 4

Thread: Custom Widget Collection

  1. #1
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Custom Widget Collection

    Hi,

    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 :-)
    Last edited by rockballad; 24th October 2009 at 17:06. Reason: updated contents

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget Collection

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget Collection

    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.

  4. #4
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom Widget Collection

    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!

Similar Threads

  1. How to use custom widget editor with QItemDelegate
    By wysman in forum Qt Programming
    Replies: 2
    Last Post: 20th May 2009, 18:20
  2. Custom Scroll Widget Sizing Problem
    By sepehr in forum Qt Programming
    Replies: 2
    Last Post: 28th November 2008, 11:42
  3. Custom Widget - First Steps
    By sekatsim in forum Qt Programming
    Replies: 8
    Last Post: 26th June 2008, 17:19
  4. Custom widget
    By zorro68 in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2008, 14:06
  5. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 15:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.