Results 1 to 6 of 6

Thread: paint Rect sometimes missing one border

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default paint Rect sometimes missing one border

    I have a QGraphicsRectItem. In its paint() method:

    Qt Code:
    1. painter->setPen(QPen(Qt::red, 1, Qt::SolidLine));
    2. painter->setBrush(QBrush(Qt::gray, Qt::Dense4Pattern));
    3. painter->drawRect(draw_rect);
    To copy to clipboard, switch view to plain text mode 




    Qt Code:
    1. QRectF Myclass::boundingRect() const
    2. {
    3. qreal adjust = 1.0;
    4. QRectF result(m_rect.topLeft().rx() - adjust/2, m_rect.topLeft().ry() - adjust/2,
    5. m_rect.width() + adjust, m_rect.height() + adjust);
    6.  
    7. return result;
    8. }
    To copy to clipboard, switch view to plain text mode 


    Most of the time, the rectangle is painted correctly. But after resize, sometimes it will miss the red line boarder, for example the left-side edge is not painted.

    I tried with following: doesn't work:

    Qt Code:
    1. QRectF Myclass::boundingRect() const
    2. {
    3. qreal adjust = 1.0;
    4. QRectF result(m_rect.topLeft().rx() - adjust, m_rect.topLeft().ry() - adjust,
    5. m_rect.width() + adjust, m_rect.height() + adjust);
    6.  
    7. return result;
    8. }
    To copy to clipboard, switch view to plain text mode 

    Any one know this problem?
    Last edited by stella1016; 19th January 2011 at 10:57.

Similar Threads

  1. QGraphicsItem and the selection rect
    By Markus in forum Qt Programming
    Replies: 0
    Last Post: 9th February 2010, 22:21
  2. How to draw the below round rect?
    By tszzp in forum Qt Programming
    Replies: 1
    Last Post: 7th January 2010, 08:58
  3. Qcombobox item rect?
    By shud in forum Qt Programming
    Replies: 0
    Last Post: 22nd November 2009, 12:07
  4. Paint Rect visible on Drag to crop image coordinate
    By patrik08 in forum Qt Programming
    Replies: 8
    Last Post: 17th March 2007, 09:04
  5. QListWidgetItem Text Rect
    By js67257 in forum Qt Programming
    Replies: 2
    Last Post: 22nd August 2006, 12: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.