pablow
29th January 2015, 14:24
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:
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/img">
<file alias="explore">resources/eye.png</file>
<file alias="export">resources/note_go.png</file>
<file alias="open">resources/delete.png</file>
<file alias="close">resources/add.png</file>
<file alias="options">resources/cog-edit-icon.png</file>
<file alias="reset">resources/arrow_undo.png</file>
</qresource>
</RCC>
ROOTDIR = $$_PRO_FILE_PWD_
SRCDIR = $$ROOTDIR/src
DESTDIR = lib
CUBE_H = $(CUBE_HEADERS)
CUBE_INC= $$CUBE_H/cube \
$$CUBE_H/cubew \
$$CUBE_H/gui
QCUSTOMPLOTDIR = $$ROOTDIR/3rd-party/qcustomplot
INCLUDEPATH += . .. $$CUBE_INC $$QCUSTOMPLOTDIR $$SRCDIR $$SRCDIR/widgets $$SRCDIR/backend
LIBS +=
QMAKE_CXXFLAGS += -std=c++11
QT += widgets printsupport
TEMPLATE = lib
CONFIG += plugin silent
RESOURCES = $$ROOTDIR/resources.qrc
HEADERS = $$files($$SRCDIR/*.h) \
$$files($$SRCDIR/widgets/*.h) \
$$files($$SRCDIR/backend/*.h) \
$$files($$QCUSTOMPLOTDIR/*.h)
SOURCES = $$files($$SRCDIR/*.cpp) \
$$files($$SRCDIR/widgets/*.cpp) \
$$files($$SRCDIR/backend/*.cpp) \
$$files($$QCUSTOMPLOTDIR/*.cpp)
target.path = $$PREFIX
target.CONFIG += no_check_exist
INSTALLS += target
TARGET = $$qtLibraryTarget(ExplorationPlugin)
OBJECTS_DIR = ./obj
MOC_DIR = ./moc
RCC_DIR = ./obj
I try to display images in a QIcon but it won't be displayed:
return QIcon( ":/img/explore" );
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
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:
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/img">
<file alias="explore">resources/eye.png</file>
<file alias="export">resources/note_go.png</file>
<file alias="open">resources/delete.png</file>
<file alias="close">resources/add.png</file>
<file alias="options">resources/cog-edit-icon.png</file>
<file alias="reset">resources/arrow_undo.png</file>
</qresource>
</RCC>
ROOTDIR = $$_PRO_FILE_PWD_
SRCDIR = $$ROOTDIR/src
DESTDIR = lib
CUBE_H = $(CUBE_HEADERS)
CUBE_INC= $$CUBE_H/cube \
$$CUBE_H/cubew \
$$CUBE_H/gui
QCUSTOMPLOTDIR = $$ROOTDIR/3rd-party/qcustomplot
INCLUDEPATH += . .. $$CUBE_INC $$QCUSTOMPLOTDIR $$SRCDIR $$SRCDIR/widgets $$SRCDIR/backend
LIBS +=
QMAKE_CXXFLAGS += -std=c++11
QT += widgets printsupport
TEMPLATE = lib
CONFIG += plugin silent
RESOURCES = $$ROOTDIR/resources.qrc
HEADERS = $$files($$SRCDIR/*.h) \
$$files($$SRCDIR/widgets/*.h) \
$$files($$SRCDIR/backend/*.h) \
$$files($$QCUSTOMPLOTDIR/*.h)
SOURCES = $$files($$SRCDIR/*.cpp) \
$$files($$SRCDIR/widgets/*.cpp) \
$$files($$SRCDIR/backend/*.cpp) \
$$files($$QCUSTOMPLOTDIR/*.cpp)
target.path = $$PREFIX
target.CONFIG += no_check_exist
INSTALLS += target
TARGET = $$qtLibraryTarget(ExplorationPlugin)
OBJECTS_DIR = ./obj
MOC_DIR = ./moc
RCC_DIR = ./obj
I try to display images in a QIcon but it won't be displayed:
return QIcon( ":/img/explore" );
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