Results 1 to 3 of 3

Thread: paint with mouse

Threaded View

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

    Default Re: paint with mouse

    Store data about the circles and access it during next mousepress.

    Qt Code:
    1. void xxx::mousePressEvent(QMouseEvent *me){
    2. // assuming QVector<QPair<QPoint, int> > circles is a member variable of the class
    3. switch(circles.count()){
    4. case 0: case 1: circles << qMakePair(me->pos(), 30); break;
    5. case 2: circles.clear();
    6. }
    7. update();
    8. }
    9. void xxx::paintEvent(QPaintEvent *pe){
    10. QPainter painter(this);
    11. for(int i=0;i<circles.count();i++){
    12. painter.drawEllipse(circles[i].first, circles[i].second, circles[i].second);
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

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

    Vincenzo (19th October 2008)

Similar Threads

  1. Mouse position on screen
    By Nippler in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2008, 14:22
  2. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 15:03
  3. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 06:13
  4. Replies: 2
    Last Post: 24th July 2006, 18:36
  5. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 19:25

Tags for this Thread

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.