[Interest] QGraphicsScene and writing to file

Ch'Gans chgans at gna.org
Thu Sep 29 00:09:15 CEST 2016


On 29 September 2016 at 10:31, Petric Frank <pfrank at gmx.de> wrote:
> Hello,
>
>
>
> i have a QGraphicsScenewhich i want to write to a file (*.png, ...).
>
>
>
> As documrmtation states i use the following:
>
> ------------------- cut ---------------------------
>
> QGraphicsScene scene;  // previously filled
>
> QRectF rect = scene->sceneRect ();
>
> QImage img (rect.width () + 1, rect.height () + 1, QImage::Format_ARGB32);
>
> img.fill (QColor (Qt::white).rgb ());
>
> QPainter p (&img);
>
> scene->render (&p);
>
> p.end ();
>
> img.save ("pict.png");
>
> ------------------- cut ---------------------------
>
>
>
> But this does not work for bigger pictures. No error message. The viewer
> simply tells that the generated *.png file are corrupted.
> The scenes reqire a width of about 100000 pixels.
>
>
>
> After some searching in the web i found out the QImage (and QPixmap) seems
> to have an internal limitation of about 32k x 32k.

Maybe render into SVG first?
http://doc.qt.io/qt-5/qsvggenerator.html

Chris

>
>
>
> The PNG-format does not have such a limitation.
>
>
>
> Any hints on how to export such a big scene to a PNG (or other) file ?
>
>
>
>
>
> Currently i use Qt 5.6.1 (Linux 64 Bit) and Qt 5.2 (Windows 7 64 Bit).
>
> Both hosts have 16 GB main memory.
>
>
>
> kind regards
>
> Petric
>
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>



More information about the Interest mailing list