开发者

How to display icon in QMessageBox?

开发者 https://www.devze.com 2023-01-12 07:51 出处:网络
I have an about box that I\'m trying to display an icon inside. Here is my code: QMessageBox about_box(this);

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.开发者_Python百科png"));
about_box.setParent(this);

about_box.exec();

Here is my resource file:

<RCC>
    <qresource prefix="/images">
        <file>logo.png</file>
    </qresource>
</RCC>


You don't need the qrc prefix:

about_box.setIconPixmap(QPixmap(":/images/logo.png"));


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消