2

I have an about box that I'm trying to display an icon inside.

Here is my code:

QMessageBox about_box(this);

about_box.setText("...");
about_box.setIconPixmap(QPixmap("qrc:/images/logo.png"));
about_box.setParent(this);

about_box.exec();

Here is my resource file:

<RCC>
    <qresource prefix="/images">
        <file>logo.png</file>
    </qresource>
</RCC>
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361

2 Answers2

8

You don't need the qrc prefix:

about_box.setIconPixmap(QPixmap(":/images/logo.png"));
Ihor Kaharlichenko
  • 5,944
  • 1
  • 26
  • 32
0

You will need this function

EDIT: I didn't see that the OP had already used this. Are you sure you're running qmake (and thus rcc) when compiling?

rubenvb
  • 74,642
  • 33
  • 187
  • 332