Results 1 to 5 of 5

Thread: QPainter - drawing new graphics without removing old stuff

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QPainter - drawing new graphics without removing old stuff

    Quote Originally Posted by rickysts View Post
    I want a delay of 0.5 seconds before drawing each point, hence the timer. Not sure how this'd work out if I had the list of all 200 points in an array... code snippet anyone?
    Qt Code:
    1. void X::timerEvent(QTimerEvent *te){
    2. QPoint pt(qRand()%width(), qRand()%height());
    3. points << pt; // assuming "points" is a QList<QPoint> class member
    4. update();
    5. }
    6.  
    7. void X::paintEvent(QPaintEvent *pe){
    8. QPainter p(this);
    9. QPen pe = p.pen();
    10. pe.setWidth(2);
    11. p.setPen(pe);
    12. foreach(const QPoint &pt, points){
    13. p.drawPoint(pt);
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to wysota for this useful post:

    rickysts (14th April 2008)

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.