I made a qrc file.
It looks like this(added prefix and then images):
<RCC>
<qresource prefix="/new/prefix1">
<file>1.jpg</file>
<file>ex.png</file>
<file>o.png</file>
<file>icon.png</file>
</qresource>
</RCC>
<RCC>
<qresource prefix="/new/prefix1">
<file>1.jpg</file>
<file>ex.png</file>
<file>o.png</file>
<file>icon.png</file>
</qresource>
</RCC>
To copy to clipboard, switch view to plain text mode
Then in .cpp file I call images like this:
palette.
setBrush(this
->backgroundRole
(),
QBrush(QImage("1.jpg")));
this->setPalette(palette);
QPalette palette;
palette.setBrush(this->backgroundRole(), QBrush(QImage("1.jpg")));
this->setPalette(palette);
To copy to clipboard, switch view to plain text mode
Then,I save,build and move the exe alone to a removable disk.
And...It doesn't work.All the images don't show(like if the qrc doesn't exist..).I add the icons to the removable disk(near exe)and it works then...
In my main.cpp I have this:
#include <QtGui/QApplication>
#include "tictactoe.h"
int main(int argc, char *argv[])
{
TicTacToe w;
w.show();
Q_INIT_RESOURCE(icons); //My qrc file is: icons.qrc
return a.exec();
}
#include <QtGui/QApplication>
#include "tictactoe.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
TicTacToe w;
w.show();
Q_INIT_RESOURCE(icons); //My qrc file is: icons.qrc
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Please help.
Bookmarks