Moving QRegion
-
hi there and thx for reading and answering this post if you can
I'm drawing in a QWidget with a QPainter Qp. Once done, I want to move the right part of my drawing to the left.
So, I wrote:
QRect r(width, 0, width + 100 , height);
r.moveLeft(0);
Qp->setClipping(true);
Qp->setClipRect(r, Qt::ReplaceClip);But noting happens. What's wrong ?
-
hi there and thx for reading and answering this post if you can
I'm drawing in a QWidget with a QPainter Qp. Once done, I want to move the right part of my drawing to the left.
So, I wrote:
QRect r(width, 0, width + 100 , height);
r.moveLeft(0);
Qp->setClipping(true);
Qp->setClipRect(r, Qt::ReplaceClip);But noting happens. What's wrong ?
@skylendar said in Moving QRegion:
But noting happens. What's wrong ?
What should happen? You don't draw anything.
Please provde a minimal, compilable example. -
QRect::moveLeft
just changes coordinates of the rectangle. It doesn't know what you use that rectangle for and certainly doesn't do any image editing.
Clipping doesn't move anything either. Those are bounds for painting that occurs after you set it.You can either redraw your thing at the new location or directly manipulate the underlying data of whatever paint device you're drawing on if it allows it.
-
@skylendar you can use QPainter alongside QTransform
First thing is to translate the painter, then draw your rectangle
an exempleQPainter painter(this); QTransform transform; transform.translate(50, 50); painter.setPen(QPen(Qt::blue, 1, Qt::DashLine)); painter.setTransform(transform); painter.drawRect(0, 0, 100, 100);
hope it helps