Results 1 to 6 of 6

Thread: Dynamic UI loading with custom widgets.

  1. #1
    Join Date
    Feb 2012
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Dynamic UI loading with custom widgets.

    Hello!
    My problem is the following. I'd like to load UI files dynamically using QUiLoader::load(). As far as I have custom widgets I have to let me my application know about them. But I'd like to make it "single file application". As far as I understand I have to register my custom widget as a plugin using subclassing from QDesignerFormEditorInterface and registering that subclass with Q_EXPORT_PLUGIN2 macro and using Q_IMPORT_PLUGIN in the beginning of my application.

    It must be I'm wrong because I get

    ..\..\lua-application\src\main.cpp(12) : warning C4101: 'qt_plugin_instance_widgets' : unreferenced local variable

    at the line there Q_IMPORT_PLUGIN is mentioned and

    error LNK2019: unresolved external symbol "class QObject * __cdecl qt_plugin_instance_widgets(void)" (?qt........

    after linking attempt.

    It must be it should be done in the way other then using Q_EXPORT_PLUGIN2/Q_IMPORT_PLUGIN couple. Could one, please, assist me with this issue? Sould it be made without separate shared plugin library?

    Thank you in advance!

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Dynamic UI loading with custom widgets.

    I don't think you are correct. That is what you need to do for making widgets available in Qt designer.

    Have you seen this?
    http://doc.qt.nokia.com/4.7-snapshot...getplugin.html
    It says that Q_EXPORT_PLUGIN2 is for using custom widget in Designer - not what you want.

    This tells you how to make a plugin for use in application.

    Have you seen this?
    http://qt-project.org/doc/qt-4.8/des...orbuilder.html
    It shows how you can load ui with no plugin needed.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Feb 2012
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dynamic UI loading with custom widgets.

    Quote Originally Posted by amleto View Post
    I don't think you are correct. That is what you need to do for making widgets available in Qt designer.

    Have you seen this?
    http://doc.qt.nokia.com/4.7-snapshot...getplugin.html
    It says that Q_EXPORT_PLUGIN2 is for using custom widget in Designer - not what you want.

    This tells you how to make a plugin for use in application.

    Have you seen this?
    http://qt-project.org/doc/qt-4.8/des...orbuilder.html
    It shows how you can load ui with no plugin needed.
    Well, yes I've seen both links you've kindly provided. But the problem I've described appears because the UI file I try to load contains nonstandard Qt widget. When I make UI of standard widgets as at article you've provided I also don't experience any problem. But when I do, I don't know how to make QUILoader know about my custom widget without making separate QtDesigner plugin.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Dynamic UI loading with custom widgets.

    Override QUiLoader::createWidget() and handle those widgets yourself. Of course you'll have to link with respective classes (without using any plugins).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2012
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dynamic UI loading with custom widgets.

    Yes, I afraid that is the only possibility to do that without separate shared libraries.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Dynamic UI loading with custom widgets.

    Why are you "afraid"? This seems like a very nice solution.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 3
    Last Post: 18th May 2012, 09:42
  2. How to speed up the dynamic lib loading?
    By wshn13 in forum Qt Programming
    Replies: 4
    Last Post: 19th April 2012, 09:55
  3. Replies: 18
    Last Post: 21st May 2010, 15:08
  4. Dynamic resource loading not work in another computer
    By GRUB in forum Installation and Deployment
    Replies: 2
    Last Post: 3rd September 2007, 10:49
  5. Switching static to dynamic ui loading
    By s_a_white in forum Newbie
    Replies: 4
    Last Post: 26th June 2006, 15:57

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.