Results 1 to 2 of 2

Thread: How to make painting on mouse move?

  1. #1
    Join Date
    Jul 2011
    Posts
    81
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default How to make painting on mouse move?

    Qt Code:
    1. void drawings::mouseMoveEvent(QMouseEvent *)
    2. {
    3. point=this->mapFromGlobal(QCursor::pos());
    4. this->repaint();
    5. }
    6. void drawings::paintEvent(QPaintEvent *event)
    7. {
    8.  
    9. painter= new QPainter(this);
    10. QPen linepen(Qt::cyan);
    11. linepen.setCapStyle(Qt::RoundCap);
    12. linepen.setWidth(30);
    13. painter->setRenderHint(QPainter::Antialiasing,true);
    14. painter->setRenderHint(QPainter::SmoothPixmapTransform,true);
    15. painter->setPen(linepen);
    16. painter->drawPoint(point);
    17. }
    To copy to clipboard, switch view to plain text mode 



    this call repaint on mouse move event.but we can see the image moving with the mouse. ie, i can see only one point at a time. i have to make painting as we draw in MS paint

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to make painting on mouse move?


Similar Threads

  1. How to add lines using mouse move?
    By athulms in forum Qt Programming
    Replies: 2
    Last Post: 10th August 2011, 07:54
  2. disable mouse move
    By karlkar in forum Newbie
    Replies: 0
    Last Post: 4th January 2011, 19:47
  3. How to move the mouse ?
    By shad0w in forum Newbie
    Replies: 3
    Last Post: 2nd November 2008, 13:55
  4. Move mouse over object
    By ToddAtWSU in forum Qt Programming
    Replies: 17
    Last Post: 3rd October 2007, 15:53
  5. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th 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.