I am trying to set icons for my QPushButtons
. I was only able to do so by putting the full path into the QPixmap
constructor.
Something like this works:
m_button->setIcon(QPixmap("C:/Users/Desktop/project/img/pic.png"));
So I think the problem does not come from the resource files. However, putting the image into my root directory does not display anything.
So this didn't work:
m_button->setIcon(QPixmap("./dog.png"));
I initially wanted to create an image folder inside my project but that didn't work either.
m_button->setIcon(QPixmap("./img/dog.png"));
You should add Qt-Resource-File to your application, add the image into it, and the call it like this:
QPixmap(":/img/dog.png");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With