Reputation: 35
I tried to set the icon of my QMainWindow object using a .qrc file:
window->setWindowIcon(QIcon(":Logo.png"));
with a .qrc file like:
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>Logo.png</file>
</qresource>
and it worked, no problem. But when I tried to use actual file path it did not work.
window->setWindowIcon(QIcon("Logo.png"))
I have checked my file paths and they are correct. Why is this happening? How can I fix it? Thanks in advance
Upvotes: 1
Views: 301
Reputation: 509
By using qrc the image is stored in the application's executable and also loaded from there. If you don't use the resource system, the image is searched relative to the current working directory. In most cases the working directory is the directory of the executable. You have to copy the image in the same folder of the application's executable.
Upvotes: 2
Reputation: 35
Thanks to @eyllanesc for the answer. I had to move the image to the folder of the excutable
Upvotes: 0