[SOLVED] Resources compilation from Qt Creator
-
Is there any way to get qrc_...cpp from Qt Creator or the only way is to go to RCC directly?
And one more strange thing - if I start Qt Designer alone it shows the tab "Resources" next to "Actions". If I edit ...ui file from Qt Creator - there is no "Resources" tab. How it is so?
And there is no visible icons in ToolBar when application is running.
There are visible icons in Qt Designer.Executed qmake from the menu of Qt Creator - no changes.
qmake-qt4 /home/user/Test.pro -r -spec linux-g++-64 CONFIG+=debug
Ubuntu, Qt 4.7.4, Qt Creator 2.3.0
Thanks!
@
#-------------------------------------------------Project created by QtCreator 2011-09-04T09:05:32
#-------------------------------------------------
QT += core gui
TARGET = Fom_Data_Studio
TEMPLATE = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
FORMS += mainwindow.ui
RESOURCES +=
resources.qrc
@
resources.qrc:
@
<RCC>
<qresource prefix="/new/prefix1"> <------------------------------- /new/prefix1 looks strange for me
<file>images/Actions-dialog-close-icon.png</file>
<file>images/Actions-document-open-icon.png</file>
<file>images/Actions-list-add-icon.png</file>
<file>images/Actions-svn-commit-icon.png</file>
<file>images/Actions-svn-update-icon.png</file>
<file>images/Actions-system-shutdown-icon.png</file>
<file>images/Actions-window-close-icon.png</file>
<file>images/cabinet-close.png</file>
<file>images/cabinet-new.png</file>
<file>images/cabinet-open.png</file>
<file>images/Places-bookmarks-icon.png</file>
<file>images/Places-folder-downloads-icon.png</file>
<file>images/Places-folder-favorites-icon.png</file>
<file>images/Status-user-online-icon.png</file>
</qresource>
</RCC>
@[EDIT: code formatting, please wrap in @-tags, Volker]
-
I'm not quite sure about your problem but /new/prefix1 is the default prefix generated by Qt Creator if you do not enter a value by yourself. It can be freely changed or removed.
The resource file is a simple XML file which can be edited out of Qt Creator using any text editor.
-
Thx for reply.
- My resource file in the post and it is obvious that it is XML. It must provide images for buttons, but it does not - this is THE ISSUE.
- Prefix - can it prevent from including *.png in application? Should I change / remove it?
- For me PREFIX should contain "images/" and file names should be without it. But I tried to do so - it does not work. Any ideas would be appreciated.
-
The file tags contain the paths relative to the directory where the qrc file lives. You must not remove the "images" part, as qrc cannot find the files then - we talk about physical files here.
The prefix attribute of the qresource tag puts that files into a virtual subdirectory in the qrc file namespace ("qrc:/"). It is prepended to the paths of the file tags. You can remove the prefix (or set it to "/").
At the moment, to access your images, would have to write
@
QImage cabinetNew(":/new/prefix1/images/cabinet-new.png");
@See "The Qt Resource System":http://developer.qt.nokia.com/doc/qt-4.7/resources.html in the docs for an detailed explanation of the features and file format.
-
Resources are beeing accessed using the :/ prefix. The prefix specified in the qresource tag is optional. Only resources specifically listed in the RCC file are added - there are no wildcards like * or automated includes.
@
// <qresource prefix="/new/prefix1">
QIcon openIcon(":/new/prefix1/images/Actions-document-open-icon.png");// <qresource prefix="/">
QIcon openIcon(":/images/Actions-document-open-icon.png");// <qresource>
QIcon openIcon(":/images/Actions-document-open-icon.png");
@