Reputation: 1
I have created a view class derived from QGraphicsView and set the backgroundBrush as an image. I want to translate the backgroundBrush. I have tried the following
// graphicsView derived from QGraphicsView
graphicsView->backgroundBrush().transform().translate(moveX, moveY);
But it is not transforming the background brush.
Upvotes: 0
Views: 198
Reputation: 29886
backgroundBrush()
and transform()
are defined as const
member functions, meaning they don't modify the object on which they are called.
You need to call setBackgroundBrush()
and setTransform()
to modify these properties:
QBrush brush = graphicsView->backgroundBrush();
brush.setTransform(QTransform::fromTranslate(moveX, moveY));
graphicsView->setBackgroundBrush(brush);
Upvotes: 1