Hi. I have a little issue with QImage and QPainter. Let me explain myself.
I have a mainWindow application. Inside i have some layouts. Inside of one of the i placed a costum Widget.
This custom Widget inherited from QWidget. The purpose of this widget is to display an image. The image is loaded from a file.
Until here, everything works perfectly.
After loading the image, some analysis is made to that image. This analysis gives me some QRects.
In the painEvent method of my custom widget i use Qpainter to first draw the image and then draw the rects.
The problem is that the rects are drawn larger then they should be.
[sharedmedia=core:attachments:23169]
In this image i show a little example. The white rectangle should be the same size as the green square.
The image a 50x50 pixels. The QRect has the correct x, y, width and height. But still, it draw a bigger rectangle.
Does anyone know that's going on?
Here is the paintEvent code:
painter->begin(this);
painter->drawImage(QPoint(0, 0), *spriteImage);
painter->setPen(Qt::white);
foreach(QRect r, spriteCoords) {
painter->drawRect(r);
}
painter->end();