Hi,
How to set the application icon in Linux?
Thanks in advance
Hi,
How to set the application icon in Linux?
Thanks in advance
Have you tried QApplication::setWindowIcon()?
Hi, I'm using QApplication::setWindowIcon() to set the icon for the application with the qt resource, but it didn't work. Could you please tell me how to set the icon in the window title application? Is there any limitation for the format of the icon? I'm using ubuntu, gnome. Can I use *.png or I must use *.ico? I really appreciate any help
are you sure that the image path is right? Could you display the image you want to set as icon on a QLabel?
I haven't tried. I'm developing in eclipse, then I have a src folder to store the header and source files. Insides the src folder, I also have an images folder which stores images and .qrc file, so the path is ":/images/icon.png". Did I make some thing wrong? Please tell me, I'm totally new to Qt. Thanks a lot
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.
If the qrc file and the image are in the same directory then possibly the ":/images/icon.png" should be ":/icon.png" but it is hard to say for sure.
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:
Qt Code:
#include <QApplication> #include <QLabel> int main(int argc, char *argv[]) { QLabel hello; hello.resize(400, 300); 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:
Qt Code:
<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.
your prefix path is images/icon... so it should be images/icon/icon.png
EDIT: oh.. tht was wrong. i forgot qrc![]()
Last edited by nish; 24th September 2010 at 10:39.
and as a hint: you can give an alias to the file itself. Then you can change the file as you like without changing you code.
It also did not work when I change the pixmap path to: ":/icon.png". I really don't know what the problem was from![]()
Ah, it works finally! Thank you very much, Lykurg and MrDeath![]()
Bookmarks