I found a working solution. I hope this can help someone else.
QBuffer b; QSvgGenerator p; p.setOutputDevice(&b); p.setSize(QSize(800,600)); p.setViewBox(QRect(0,0,800,600)); QPainter painter; painter.begin(&p); painter.setRenderHint(QPainter::Antialiasing); this->scene->render(&painter); painter.end(); QMimeData * d = new QMimeData(); d->setData("image/svg+xml",b.buffer()); QApplication::clipboard()->setMimeData(d,QClipboard::Clipboard); Thanks to everyone who took time to read my original post. ----- Mail original ----- De: helfertho...@free.fr À: "Qt Interest" <interest@qt-project.org> Envoyé: Samedi 14 Septembre 2013 08:12:20 Objet: [Interest] how render a qgraphicsscene to svg and paste it to the clipboard Hi, I am using the qgraphicsview/qgraphicscene framework. I am able to write file from the drawn scene to multiple file formats, including svg using QtSvg. I want to be able to copy the scene to the clipboard. For a bitmap copy, i am using the following code: // Selections would also render to the file this->scene->clearSelection(); // Create the image with the exact size of the shrunk scene QImage image(scene->sceneRect().size().toSize(), QImage::Format_ARGB32); image.fill(Qt::transparent); QPainter painter; painter.begin(&image); painter.setRenderHint(QPainter::Antialiasing); this->scene->render(&painter); painter.end(); QApplication::clipboard()->setImage(image,QClipboard::Clipboard); which works great. However I wonder if I can do copy the scene as svg data to the clipboard. Does anybody know how to do it ? Thanks for any help. Helfer Thomas _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest