首页| 论坛| 消息

标题:我将多个图元选中,用QGraphicsItemGroup组合它们,想导出png图,还是没有好的思路,求众仙指点
作者:shixingya
日期:2017-12-04 12:45
内容:

void PaintView::onAssemblageAction(bool)
{
QListselectItems=this->scene()->selectedItems();
QGraphicsItemGroup * groupItems =this->scene()->createItemGroup(selectItems);
QRectF rect =groupItems->boundingRect();

QGraphicsScene*scene =new QGraphicsScene();
scene->setSceneRect(rect);
for(int i=0; iaddItem(sp);
}
scene->clearSelection();
QImage image(rect.width(),rect.height(),QImage::Format_ARGB32);
image.fill(Qt::transparent);//用透明色填充
QString pngName = "D:/scene44test.png";
QPainter painter(&image);
painter.setRenderHint(QPainter::Antialiasing);
scene->render(&painter);
bool saveSuccess =image.save(pngName);
for(int i=0; i


#1 [shixingya 12-04 12:47]
上面的方式 虽然可以曲线救国,但是相信有更好的方式 求推荐

回复 发表
主题 版块