Qt Update Pixmap of QGraphicsPixmapItem

前端 未结 1 382
[愿得一人]
[愿得一人] 2021-01-13 16:08

I am using the QGraphicsPixmapItem to show an image on the display. Now, I want to be able to update this image on the fly, but I seem to be running into some issues.

<
相关标签:
1条回答
  • 2021-01-13 17:15

    Why FGS you are subclassing QGraphicsPixmapItem? QGraphicsPixmapItem has all functionality you need. And those new fields you have added does nothing, they only try replicate functionality which is already there (but with this implementation it does nothing).

    This suppose to be something like that:

    QPixmp image(":/images/alive.png");
    QGraphicsPixmapItem *enemyItem = scene.addPixmap(image.scaledToWidth(20));
    enemyItem->setPos(20, 20);
    
    // and after something dies
    QPixmap dieImage(":/images/dead.png");
    enemyItem->setPixmap(dieImage);
    
    0 讨论(0)
提交回复
热议问题