Results 1 to 4 of 4

Thread: Debug resource system

  1. #1
    Join Date
    Jan 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Debug resource system

    Hi everyone

    I have a problem using the resource system. I am not able
    to display images linked into the resource system.

    My project contains a resource.qrc and plugin.pro as follows:

    Qt Code:
    1. <!DOCTYPE RCC><RCC version="1.0">
    2. <qresource prefix="/img">
    3. <file alias="explore">resources/eye.png</file>
    4. <file alias="export">resources/note_go.png</file>
    5. <file alias="open">resources/delete.png</file>
    6. <file alias="close">resources/add.png</file>
    7. <file alias="options">resources/cog-edit-icon.png</file>
    8. <file alias="reset">resources/arrow_undo.png</file>
    9. </qresource>
    10. </RCC>
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. ROOTDIR = $$_PRO_FILE_PWD_
    2. SRCDIR = $$ROOTDIR/src
    3. DESTDIR = lib
    4. CUBE_H = $(CUBE_HEADERS)
    5. CUBE_INC= $$CUBE_H/cube \
    6. $$CUBE_H/cubew \
    7. $$CUBE_H/gui
    8.  
    9. QCUSTOMPLOTDIR = $$ROOTDIR/3rd-party/qcustomplot
    10.  
    11. INCLUDEPATH += . .. $$CUBE_INC $$QCUSTOMPLOTDIR $$SRCDIR $$SRCDIR/widgets $$SRCDIR/backend
    12. LIBS +=
    13.  
    14. QMAKE_CXXFLAGS += -std=c++11
    15. QT += widgets printsupport
    16.  
    17. TEMPLATE = lib
    18. CONFIG += plugin silent
    19.  
    20. RESOURCES = $$ROOTDIR/resources.qrc
    21.  
    22. HEADERS = $$files($$SRCDIR/*.h) \
    23. $$files($$SRCDIR/widgets/*.h) \
    24. $$files($$SRCDIR/backend/*.h) \
    25. $$files($$QCUSTOMPLOTDIR/*.h)
    26.  
    27. SOURCES = $$files($$SRCDIR/*.cpp) \
    28. $$files($$SRCDIR/widgets/*.cpp) \
    29. $$files($$SRCDIR/backend/*.cpp) \
    30.   $$files($$QCUSTOMPLOTDIR/*.cpp)
    31.  
    32. target.path = $$PREFIX
    33. target.CONFIG += no_check_exist
    34.  
    35. INSTALLS += target
    36.  
    37. TARGET = $$qtLibraryTarget(ExplorationPlugin)
    38. OBJECTS_DIR = ./obj
    39. MOC_DIR = ./moc
    40. RCC_DIR = ./obj
    To copy to clipboard, switch view to plain text mode 

    I try to display images in a QIcon but it won't be displayed:

    Qt Code:
    1. return QIcon( ":/img/explore" );
    To copy to clipboard, switch view to plain text mode 

    As you can see I am building a library as target.
    I get no warnings/errors during the build. I also
    compared the file size of the resulting library if I
    include different sized images into the resource.qrc.
    And - as expected - the size of the resulting library changes.
    Therefore, I assume linking the resources into the library is fine.

    Do you have any ideas what can be wrong?
    Is there an option to show all available resource strings available
    in the resource system?

    Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Debug resource system

    Quote Originally Posted by pablow View Post
    Is there an option to show all available resource strings available
    in the resource system?
    QDir can operate on the resource directory tree just like on the actual filesystem.
    I.e.
    Qt Code:
    1. QDir dir(":/");
    To copy to clipboard, switch view to plain text mode 
    would be the equivalent of the root directory.

    Cheers,
    _

  3. #3
    Join Date
    Jan 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Debug resource system

    Ok, thank you.
    In fact, my resources are not included in the resource tree at all.
    I only see the resources of the parent qt application using my library.

    My library is a dynamic library. Therefore, there should be no need to
    use Q_INIT_RESOURCE(), right?

  4. #4
    Join Date
    Jan 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Debug resource system

    Solved:

    The problem was that both the main application and my library were using
    "resources.qrc" as file name for the resource file. Apparently, that did not work.
    I renamed the resource file in my library project and now it works.

Similar Threads

  1. Cannot copy js file from resource to file system
    By kalma in forum Qt Programming
    Replies: 1
    Last Post: 1st January 2015, 15:10
  2. Replies: 1
    Last Post: 28th June 2013, 01:44
  3. Replies: 8
    Last Post: 21st March 2011, 12:40
  4. Replies: 3
    Last Post: 28th July 2010, 14:14
  5. Replies: 11
    Last Post: 22nd March 2006, 19:06

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.