Results 1 to 3 of 3

Thread: Qt Resource images not showing while executing

  1. #1
    Join Date
    Mar 2018
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Qt Resource images not showing while executing

    I'm also facing the issue of resource images not visible when the app is running. I have a plugin-based architecture. Lets say,

    NavControls, a staticLib, in which we have the icons on buttons.
    The NavControls.lib is used by a Plugin (VIEWERSHARED_EXPORT). I added it in the .pro of the Viewer Plugin
    Qt Code:
    1. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../Deploy/bin/release/ -lNavControls
    2. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../Deploy/bin/debug/ -lNavControls
    3.  
    4. INCLUDEPATH += $$PWD/../NavControls
    5. DEPENDPATH += $$PWD/../NavControls
    To copy to clipboard, switch view to plain text mode 
    This Viewer plugin implements an Interface.
    Finally, I load the plugin in the app, by QPluginLoader class..
    The plugin loads without any warnings, but the images are missing on the navControl's buttons.

    Please suggest what I'm missing!!

    Thanks,
    Sayan

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    3,765
    Thanks
    216
    Thanked 582 Times in 572 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Qt Resource images not showing while executing

    You probably need to put the Q_INIT_RESOURCE() macro in main() following the declaration of your QApplication object:

    Qt Code:
    1. Q_INIT_RESOURCE( name-of-lib );
    To copy to clipboard, switch view to plain text mode 

    Where "name-of-lib" is the file name of your static library, without quotes and without the .lib extension. This macro tells Qt to load the resources from the library so they can be used in the app.
    <=== 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.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,480
    Thanks
    13
    Thanked 1,568 Times in 1,497 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt Resource images not showing while executing

    It is also possible you not have the necessary Qt image format plugins deployed.

Similar Threads

  1. App cannot load resource images - why?
    By MarkoSan in forum Newbie
    Replies: 2
    Last Post: 13th September 2015, 21:24
  2. Loading images from resource files in webkit
    By redserpent7 in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2015, 13:01
  3. GIF images in qt resource file
    By A9am in forum Newbie
    Replies: 3
    Last Post: 25th November 2013, 09:36
  4. How to add 50 MB of images to resource file ??????
    By prajnaranjan.das in forum Newbie
    Replies: 5
    Last Post: 24th December 2010, 04:56
  5. QWebView with .css, .js and images in a resource file...
    By sublimer in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2010, 12:27

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.