Results 1 to 6 of 6

Thread: Error while redrawing using QPainter Class

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    36
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Error while redrawing using QPainter Class

    Hi All,

    I am using QPainter class to draw line on the button event.
    I am using three push button on which every button different layouts of the line will draw.

    First time it works well but when I press rapidly few times then overwriting will occur.
    I am using painter.eraseRect(0,0,281,191); but it not works

    Can anyone help me to clear the label everytime when I draw.
    In Qt there is no painter.clear() properties.

    How can I clear the screen every time before I draw.

    Qt Code:
    1. In 1st Push button I write
    2.  
    3. QPixmap pix(281,191);
    4. QPen Pen((QColor::QColor (255,255,255,255)),2);
    5.  
    6. QLineF line1(0,50,281,50);
    7. painter.eraseRect(0,0,281,191);
    8. painter.begin(&pix);
    9. painter.setPen(Pen);
    10. painter.drawLine(line1);
    11. painter.end();
    12.  
    13. In 2nd button I write
    14.  
    15. QPixmap pix(281,191);
    16. QPen Pen((QColor::QColor (255,255,255,255)),2);
    17. QLineF line1(60,50,281,50);
    18. QLineF line2(60,141,281,141);
    19. QLineF line3(60,0,60,191);
    20. painter.eraseRect(0,0,281,191);
    21. painter.begin(&pix);
    22. painter.setPen(Pen);
    23. painter.drawLine(line1);
    24. painter.drawLine(line2);
    25. painter.drawLine(line3);
    26. painter.end();
    27.  
    28. so on..
    To copy to clipboard, switch view to plain text mode 
    Last edited by sosanjay; 16th December 2009 at 08:02.

Similar Threads

  1. How to drawline in a QWidget or any onther?
    By yangyunzhao in forum Qt Programming
    Replies: 2
    Last Post: 28th August 2009, 07:19
  2. Correct way to clear a form?
    By Walter in forum Newbie
    Replies: 7
    Last Post: 16th August 2009, 18:54
  3. QLineEdit: with builtin clear button, how to
    By chezifresh in forum Qt Programming
    Replies: 3
    Last Post: 5th May 2009, 20:05
  4. Replies: 1
    Last Post: 14th May 2008, 19:35
  5. QTextBrowser Clear selection
    By sreedhar in forum Newbie
    Replies: 2
    Last Post: 4th April 2006, 08:23

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
  •  
Qt is a trademark of The Qt Company.