[Interest] QGraphicsScene and writing to file

Petric Frank pfrank at gmx.de
Wed Sep 28 23:31:37 CEST 2016


Hello,

i have a QGraphicsScenewhich i want to write to a file (*.png, ...).

As documrmtation states i use the following:
------------------- cut ---------------------------
QGraphicsScene[1] 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.

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


--------
[1] http://doc.qt.io/qt-5/qgraphicsscene.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160928/ae94d07c/attachment.html>


More information about the Interest mailing list