Qt 清空QPixMap
1、如果为使用场景视图框架:
2、如果使用了场景视图框架。
那就用QGraphicsScene::removeItem(QGraphicsItem *item);
例如:
if(image->load(fileName)) {
//重绘背景图 graphicsView->_orignal_backGround = false; QImage mirroredImage = image->mirrored(false, true); graphicsView->map = QPixmap::fromImage(mirroredImage); mapitem = _scene->addPixmap( graphicsView->map); mapitem->setFlag(QGraphicsItem::ItemIsFocusable); mapitem->setZValue(-1); }
删除图片
//清空背景 if(mapitem !=nullptr) {
_scene->removeItem(mapitem); }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/203299.html原文链接:https://javaforall.net
