
Originally Posted by
Lykurg
its hard to tell if you are doing it right without seeing any piece of code. So as said, simply add a QLabel to your mainwindow and set a pixmap on it. When you create the pixmap use the exact same path as you do for the window icon. Check if you can see the icon on the label. Then we move further.
I tried with the QLabel, but it didn't work too
. Maybe there was something wrong in my qrc file. I'm developing using eclipse running on ubuntu. I created 2 new folders: src and images. In src folder, I put the main function in main.cpp which is:
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
hello.resize(400, 300);
QPixmap pixmap
(":/images/icon.png");
hello.setPixmap(pixmap);
hello.show();
return app.exec();
}
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel hello;
hello.resize(400, 300);
QPixmap pixmap(":/images/icon.png");
hello.setPixmap(pixmap);
hello.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
In the images folder, I put the icon.png and hello.qrc files. The qrc file is generated by eclipse, which is:
<RCC>
<qresource prefix="/images/icon">
<file>icon.png</file>
</qresource>
</RCC>
<RCC>
<qresource prefix="/images/icon">
<file>icon.png</file>
</qresource>
</RCC>
To copy to clipboard, switch view to plain text mode
When running, the form displayed nothing. Could you please see what wrong here? Thank you very much for your help.
Bookmarks