[Interest] how render a qgraphicsscene to svg and paste it to the clipboard

Constantin Makshin cmakshin at gmail.com
Sat Sep 14 10:03:07 CEST 2013


Use a QByteArray as the output device for QSvgGenerator and copy it to
the clipboard using QClipboard::setMimeData().

On 09/14/2013 10:12 AM, helferthomas at free.fr wrote:
> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130914/94361db2/attachment.sig>


More information about the Interest mailing list