Important: Please read the Qt Code of Conduct -

SetPixmap in custom QGraphicsPixmapItem class not working

  • Hi.
    I've come here for help on an issue that I can't solve after quite some time looking for help.
    I created a class which "derives" from a QGraphicsPixmapItem. In the constructor I want to set the pixmap from a resource file.
    I've tried loading with "qrc:/..." or "://..." but there is no help. The resource file name is "image.qrc" and the prefix /Lshape. The file name is "Lshape1.png".
    In the scene I do:
    @ Lshape * lshape = new Lshape();


    EDIT: I've also tried setPixmap(QPixmap(":/Lshape/Lshape1.png"))--;

  • Try setting an alias for the pixmap. Also, post your qrc file.

Log in to reply