Solved How to show QGraphicsScene background and border but do not save into image ?
-
And why QGraphicsScene background fill full of QGraphicsView ?
scene->setBackgroundBrush(pixmap); void MainWindow::open(QString filepath) { scene->clear(); QPixmap pixmap(filepath); QGraphicsPixmapItem *GPI = scene->addPixmap(pixmap); GPI->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable); scene->setSceneRect(0, 0, pixmap.width(), pixmap.height()); } void MainWindow::save(QString filepath) { QSize size(scene->width(), scene->height()); QImage image(size, QImage::Format_ARGB32); QPainter painter(&image); scene->render(&painter); image.save(filepath); }
-
@sonichy
try painting the background pixmap in QGraphicsView::drawBackground(), this way it shouldn't be taken into account by QGraphicsScene::render() -
@raven-worx OK!
ui->graphicsView->setBackgroundBrush(pixmap);