PDA

View Full Version : QGraphicsItemGroup - draw as QPixmap



Leszek
24th October 2010, 19:51
Hello.

I created my own format for reading/writting objects from scene.
It works fine, but when I try to create QPixmap by using QGraphicsItemGroup
I have some problems.



QPixmap pixmap(600, 150);
QPainter painter(&pixmap);

... loading data from file....
QGraphicsItem* item = importers.getData().at(0);
QStyleOptionGraphicsItem opt;
painter.setRenderHints(QPainter::Antialiasing);
QGraphicsItemGroup* group = qgraphicsitem_cast<QGraphicsItemGroup*>(item);

BOOST_FOREACH(QGraphicsItem* itemc, group->children()) {
itemc->paint(&painter, &opt);
}

scene->addPixmap(pixmap);


Below code used to store information:



QDataStream ds;

ds << path();
QTransform parentTransforms;
if(parentItem())
parentTransforms = parentItem()->transform();

ds << parentTransforms;
ds << transform();


Below code used to load information:



QPainterPath path;
QTransform parentTransforms;
QTransform transforms;

ds >> path >> parentTransforms >> transforms;

setPath(path);

setTransform(parentTransforms);
setTransform(transforms, true);


Problem: QPainterPath starts drawing from position ...x=420(before drawing moveTo is called)

What kind of informations should I save for QPainterPath, to restore it corectly ?
Thanks, for reply.

Leszek
26th October 2010, 21:38
This problem was reolved in thread
http://www.qtcentre.org/threads/35379-QGraphicsItemGroup-store-informations-about-children.?p=163407