[SOLVED]problem in referring to resource image file



  • Hello,
    I added an image file door_open.png to my .qrc file with prefix im .But when I used the image file in my code @QAction *liulanAct->setIcon(":/im/door_open.png");@

    I received an error message Can't transform parameter 1 from const char [21] to const QIcon &.
    Here is the code of .qrc file
    @<RCC>
    <qresource prefix="/im">
    <file>Image/door_open.png</file>
    </qresource>
    </RCC>@

    My IDE is Qt Creator.
    Thank you for your attention.



  • The Error Message has told you how to do.

    You should pass a QIcon instead of a string.

    @
    QAction *liulanAct->setIcon(QIcon(":/im/door_open.png"));

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.