PDA

View Full Version : QBrush TexturePattern alignment



Caius Aérobus
23rd November 2008, 11:56
Hello,
I create a QBrush with a TexturePattern and set a pixmap like this:


QPixmap pm("eye.png");
this->brush = QBrush(pm);
QRect r(100, 100, pm.width(), pm.height());
painter.fillRect(r, this->brush);

The results is below, ie the image left corner is in the (about) middle of the QRect, so what did I miss?

nezticle
23rd November 2008, 13:16
Are you sure you didn't mean for your QRect to be:


QRect r(0, 0, pm.width(), pm.height());

Caius Aérobus
23rd November 2008, 14:41
Hmmmm, it turns out that it works!
So let me try to understand how it works: the pixmap is actually mapped not on the QRect itself but rather on the whole canvas, in a tile manner, and the QRect acts as a window on this tiled canvas, right?
So my question is now: how to map the pixmap on the QRect, whatever location this QRect is drawn at?