PDA

View Full Version : BoundingRect problem



mvbhavsar
28th January 2015, 19:43
Hello,

I have following code which gives me wrong output





MyRect::MyRect(QGraphicsItem *parent):QGraphicsRectItem(parent)
{
setRect(0,0,100,100);
qDebug() << "Bounding rect is " << boundingRect();
}




And the output is as follows.

Bounding rect is QRectF(-0.5,-0.5 101x101)

Why x,y,width and height has changed than what I set. Because of this change, this item move topside when x,y,width and height is added with some factor at runtime.


Regards

Manish

Radek
28th January 2015, 20:01
Looks like the pen width correction. To check this, increase pen width before creating the rectangle and see the debug output.

mvbhavsar
29th January 2015, 06:49
Thanks Radek.
Yes, it's pen width which is making correction.