Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SetPixmap in custom QGraphicsPixmapItem class not working

SetPixmap in custom QGraphicsPixmapItem class not working

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 706 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    noastick
    wrote on last edited by
    #1

    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.
    @Lshape::Lshape():-QGraphicsPixmapItem(QPixmap(":/image/Lshape1"))-
    {
    setPixmap(QPixmap(":/image/Lshape1.png"));
    }@
    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();
    lshape->setPos(100,0);
    addItem(lshape);@

    Thanks.

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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved