Results 1 to 6 of 6

Thread: Creating DLL with dialogs for Qt app

  1. #1
    Join Date
    Sep 2011
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Creating DLL with dialogs for Qt app

    Hello !

    I am creating Qt application which should be able to load DLLs with Qt GUI (dialogs, forms) used as extension to the main App. I am facing problem with creating these dialogs. They obviously need QApplication but i dont want to make another one inside DLL since the dialogs then appear as completely separate App. Despite my effort ive had no luck so far to find any example or hints how to do this properly. Should i somehow pass QApplication pointer to the DLL? If this is the way how should i use the pointer inside DLL? I can provide more details if needed. Thanks in advance.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,618
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Creating DLL with dialogs for Qt app

    Use the Qt Plugin mechanism to load your extension containing the classes representing your widgets into your application. Create instances of your extension widgets (using a factory method as the interface of the plugin perhaps) and use them. You need the QApplication instance to exist when you use (instantiate) the widget. Loading the plugin is not using the widget.

  3. #3
    Join Date
    Sep 2011
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Creating DLL with dialogs for Qt app

    Hello,

    Thanks for the reply. I was looking on the plugins but i would like to make it possible with DLL. I found this article in archive : http://www.qtcentre.org/archive/index.php/t-2570.html
    Im curious about exactly this phrase by wysota: "Maybe it's better not to create a QApplication inside the dll and just use the one provided by the main binary?"

    It looks like it can be done easily since it is "usual" way to do it. But still i dont know how.

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Creating DLL with dialogs for Qt app

    I think ChrisW67 answer is enough for what you are trying to do - users of the dll should use the factory method to create your custom widgets, by that time they already should have the QApplication instance up and running. If you need the QApplication instance yourself inside some custom class, just use QApplication::instance() method to retrieve it. The fact that your method is "placed" in separate dll is meaningless in that case, still it will be the same instance of QApplication, the one created by the user.

  5. #5
    Join Date
    Sep 2011
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Creating DLL with dialogs for Qt app

    So, theres no way of doing it without plugin mechanism? Sorry for maybe being stubborn bud in this case it would be better for me doing it the classic dll way.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,618
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Creating DLL with dialogs for Qt app

    The DLL is part of the same address space as your main application once loaded (by LoadLibraryEx on Windows). If you don't use the Qt plugin mechanism then you have to resolve names in the library yourself (GetProcAddress() on Windows) and do all the plumbing. Your "classic DLL", which differs from a Qt plugin only that it is more effort to manage and less portable, can call QApplication::instance() just the same as a routine in the main program exe.

    If your "classic DLL" requirement is because you want to load the resulting DLL into a non-Qt program then you have a different issue, not the one you described in your first post, and not the one from your linked post.
    Last edited by ChrisW67; 21st September 2011 at 23:25.

Similar Threads

  1. Creating modal dialogs
    By Luc4 in forum Qt Programming
    Replies: 8
    Last Post: 17th June 2010, 10:35
  2. using native kde-dialogs
    By #andi# in forum Newbie
    Replies: 2
    Last Post: 11th August 2009, 10:50
  3. Translation of app and Qt Dialogs
    By honza in forum Qt Programming
    Replies: 4
    Last Post: 11th May 2009, 17:53
  4. Qt dialogs in other lenguages...
    By Sparhawk in forum Qt Programming
    Replies: 3
    Last Post: 13th June 2008, 11:18
  5. Skinned dialogs
    By Lele in forum Qt Programming
    Replies: 24
    Last Post: 9th August 2007, 08:43

Tags for this Thread

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.