Results 1 to 3 of 3

Thread: BoundingRect problem

  1. #1
    Join Date
    Jun 2010
    Posts
    97
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default BoundingRect problem

    Hello,

    I have following code which gives me wrong output


    Qt Code:
    1. MyRect::MyRect(QGraphicsItem *parent):QGraphicsRectItem(parent)
    2. {
    3. setRect(0,0,100,100);
    4. qDebug() << "Bounding rect is " << boundingRect();
    5. }
    To copy to clipboard, switch view to plain text mode 


    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

  2. #2
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: BoundingRect problem

    Looks like the pen width correction. To check this, increase pen width before creating the rectangle and see the debug output.

  3. #3
    Join Date
    Jun 2010
    Posts
    97
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: BoundingRect problem

    Thanks Radek.
    Yes, it's pen width which is making correction.

Similar Threads

  1. qpainter drawtext boundingRect problem
    By hayzel in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2015, 06:31
  2. boundingRect problems
    By mefalo in forum Qt Programming
    Replies: 3
    Last Post: 8th December 2010, 12:55
  3. Replies: 0
    Last Post: 3rd February 2010, 14:50
  4. boundingRect()?
    By aaron in forum Qt Programming
    Replies: 6
    Last Post: 21st April 2009, 09:43
  5. QGraphicsItem -> boundingRect()
    By harakiri in forum Qt Programming
    Replies: 4
    Last Post: 6th March 2008, 15:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.