문제

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>
도움이 되었습니까?

해결책

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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top