I tried to set an image to a Qt pushbutton using this widely known code.
QPixmap *pic = new QPixmap(":/images/logo.png");
QIcon *icon = new QIcon(*pic);
ui->pushButton->setIcon(*icon);
ui->pushButton->setIconSize(QSize(pic->width(), pic->height()));
Here's my qrc file
<RCC>
<qresource prefix="/images">
<file>images/logo.png</file>
</qresource>
</RCC>
Even though the program compiles, always a runtime exception occurs at
QPixmap *pic = new QPixmap(":/images/logo.png");
When I tried printing *pic on output console, it showed that pic = QPixmap(QSize(0, 0) ). i.e. it is null. Any ideas as to where I went wrong?
Thanks in advance!