Results 1 to 5 of 5

Thread: Is it possible to add QT resources to a DLL?

  1. #1
    Join Date
    Mar 2006
    Posts
    46
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Is it possible to add QT resources to a DLL?

    I have a DLL in which I would like to embed a file using the Qt resource system. I do this for Qt EXEs all of the time without any problems. It seems like the Qt resource system manages resource at the application level however, and so I'm a little unclear if it would be possible to add Qt resources to a DLL. I also don't want the DLL's ability to have resources to interfere with any Qt executable which might be hosting the DLL in terms of its resources. Is it possible to build resource spaces at the DLL level?

    Colby

  2. #2
    Join Date
    May 2008
    Posts
    155
    Thanked 15 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Is it possible to add QT resources to a DLL?

    There is no problem with Qt resources in .dll. Just add a RESOURCES += foo.qrc line to the .dll's .pro file as usual.

    To prevent resource clashs, one typically creates 'namespaces' by naming the resources, say, ":mydll/images/image1.jpg" .

  3. The following user says thank you to ktk for this useful post:

    cboles (25th August 2008)

  4. #3
    Join Date
    Mar 2006
    Posts
    46
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is it possible to add QT resources to a DLL?

    Thanks. I'll check that out. My DLL and app will not / may not have a QApplication, but I'm assuming that Q_INIT_RESOURCE() declarations are all that is needed to make the resource accessible...

  5. #4
    Join Date
    Oct 2016
    Posts
    7
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Symbian S60

    Default Re: Is it possible to add QT resources to a DLL?

    i have the same problem i want my application resources (icon,image,voice...) to be stored in a ddl file and you is in my appliacation how can i do that please

  6. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Is it possible to add QT resources to a DLL?

    As the previous post in this thread says, you have to add a call to Q_INIT_RESOURCE() in the main.cpp file. If your DLL is named "MyDLL.dll", then:

    Qt Code:
    1. Q_INIT_RESOURCE( MyDLL );
    To copy to clipboard, switch view to plain text mode 

    The call should be placed -after- you have declared your QApplication variable instance.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Resources cannot be read under Designer
    By Flakes in forum Qt Tools
    Replies: 1
    Last Post: 24th January 2008, 09:28
  2. Distributing an application with resources
    By ntp in forum Qt Programming
    Replies: 3
    Last Post: 6th October 2007, 02:46
  3. Compiled resources in shared library
    By magland in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2007, 05:57
  4. How to export resources in libraries on LINUX using Qt????
    By Shuchi Agrawal in forum Qt Programming
    Replies: 8
    Last Post: 1st June 2007, 11:14
  5. problem with resources
    By SuperSonik in forum Installation and Deployment
    Replies: 2
    Last Post: 15th February 2007, 11:58

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.