Results 1 to 2 of 2

Thread: problem in painter fillRect

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default problem in painter fillRect

    hi friends,
    normally using fillRect() we will fill the entire rect with some color ..
    but if i want to fill RoundRect .. how can i use fillRect ..
    my code
    Qt Code:
    1. QRectF rect1(0, 0, 100, 50);
    2. QRectF rect2(5, 5, 90, 40);
    3. painter->setPen(QColor(160, 160, 160));
    4. painter->setBrush(QColor(104, 104, 104));
    5. painter->drawRoundRect(rect1);
    6. painter->drawRoundRect(rect2);
    7. painter->fillRect(7, 7, 86, 36, QColor(51, 51, 51));
    To copy to clipboard, switch view to plain text mode 

    but it showing a box inside the rect2 . how can i fill the entire rect2 with QColor ...

    currently i change my code as
    Qt Code:
    1. QRectF rect1(0, 0, 100, 50);
    2. QRectF rect2(5, 5, 90, 40);
    3. painter->setPen(QColor(160, 160, 160));
    4. painter->setBrush(QColor(104, 104, 104));
    5. painter->drawRoundRect(rect1);
    6. painter->setBrush(QColor(51, 51, 51));
    7. painter->drawRoundRect(rect2);
    To copy to clipboard, switch view to plain text mode 
    "Behind every great fortune lies a crime" - Balzac

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: problem in painter fillRect

    use QPainterPath instead. For example:
    Qt Code:
    1. path.addRoundedRect(someRect, xradius, yradius);
    2. painter.drawPath(path);
    3. painter.fillPath(path, QColor(104, 104, 104));
    To copy to clipboard, switch view to plain text mode 
    Last edited by faldzip; 27th May 2009 at 13:44. Reason: spelling error
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. The following user says thank you to faldzip for this useful post:

    wagmare (27th May 2009)

Similar Threads

  1. Problem with Painter in Qt4.4.1
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 1st September 2008, 13:47
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. QT 4.4.0 Upgrade QPainter Problem
    By ChrisReath in forum Qt Programming
    Replies: 4
    Last Post: 13th May 2008, 15:25
  4. use Qpainter to draw lines + problem in my painter
    By ReSu in forum Qt Programming
    Replies: 4
    Last Post: 5th March 2008, 15:44
  5. painter problem in new Qt-4.2.3 installation
    By impeteperry in forum Installation and Deployment
    Replies: 2
    Last Post: 2nd May 2007, 05:34

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.