A Dimarts 29 Abril 2008, Andreas Aardal Hanssen va escriure:
> Andreas Aardal Hanssen wrote:
> > The difference seems to be that QGraphicsSvgItem::paint leaves the
> > painter in a translated state in 4.4, whereas in 4.3 it didn't. Wrapping
> > the call to QGraphicsSvgItem::paint inside a QPainter::save/restore pair
> > should work around the bug.
> > Yes, it seems to be a bug, we'll try to fix it as soon as possible.
>
> On closer inspection, the translation bug that this example shows seems to
> be a bugfix, not a regression.
Ok, thanks for dedicating so much time to me :-)
Good i'm no longer using a bug to get the behaviour i wanted.
Albert
> The painter was previously left in a funny
> state, but now it is no longer. If you run this example, which renders
> before and after the call to QGraphicsSvgItem::paint(), you'll see that the
> two rects are rendered at the right spot in 4.4, but in 4.3 (uncomment the
> cache line in the constructor) the box is drawn in device coordinates.
>
> The cache mode implementation in QGraphicsSvgItem previously left the
> painter in device space, but as of 4.4, the painter state is properly
> restored.
>
> #include <QApplication>
> #include <QGraphicsView>
> #include <QGraphicsSvgItem>
>
> class ToDraw : public QGraphicsSvgItem
> {
> public:
> ToDraw() : QGraphicsSvgItem("norway.svg")
> {
> setCacheMode(NoCache);
> }
>
> void paint ( QPainter * painter, const
> QStyleOptionGraphicsItem * option, QWidget * widget )
> {
> painter->setPen(QPen(Qt::blue));
> painter->setBrush(QColor(Qt::blue));
> painter->drawRect(-10, -10, 20, 20);
>
> QGraphicsSvgItem::paint(painter, option, widget);
>
> painter->setPen(QPen(Qt::black));
> painter->setBrush(QColor(Qt::black));
> painter->drawRect(0, 0, 10, 10);
>
> }
> };
>
>
> int main(int argc, char *argv[])
> {
> QApplication a(argc, argv);
>
> QGraphicsView *gv = new QGraphicsView();
> QGraphicsScene *scene = new QGraphicsScene();
> gv->setScene(scene);
> gv->show();
> gv->resize(800, 600);
>
> ToDraw *item = new ToDraw;
> item->setPos(QPoint(0,0));
> item->setZValue(0);
> scene->addItem(item);
>
> return a.exec();
> }
To unsubscribe - send "unsubscribe" in the subject to [EMAIL PROTECTED]