Results 1 to 2 of 2

Thread: Handling longpress.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2011
    Posts
    120
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    9

    Default Handling longpress.

    Hi
    I want to create longpress of a painted shape, how it should done?
    Waiting for your reply.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: Handling longpress.

    What is a painted shape, I mean what is the Qt type used for it

    If your painted shape if of type QWidget then, it can be this way

    Qt Code:
    1. void MyWidget::mousePressEvent(QMouseEvent* event)
    2. {
    3. long_press_timer = startTimer(4000); // 4 second Longpress
    4. }
    5.  
    6. void MyWidget::mouseReleaseEvent(QMouseEvent* event)
    7. {
    8. long_press_timer = 0;
    9. }
    10.  
    11. void MyWidget::timerEvent(QTimerEvent* event)
    12. {
    13. if(long_press_timer == event->timerId())
    14. {
    15. // processes long press
    16. }
    17. long_press_timer = 0;
    18. killTimer(vent->timerId());
    19. }
    To copy to clipboard, switch view to plain text mode 

    If your shape is of type QGraphicsObject, it is similar, implement these

    Qt Code:
    1. void MyGraphicsObject::mousePressEvent(QGraphicsSceneMouseEvent* event);
    2. void MyGraphicsObject::mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
    3. void MyGraphicsObject::timerEvent(QTimerEvent* event);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. file handling
    By santakdalai90 in forum Qt Programming
    Replies: 1
    Last Post: 22nd October 2009, 20:50
  2. Bug in MDI handling
    By daren in forum Qt Programming
    Replies: 1
    Last Post: 31st March 2009, 14:13
  3. event handling...
    By xyzt in forum Qt Programming
    Replies: 1
    Last Post: 25th March 2008, 07:16
  4. handling XClientMessageEvent
    By qtdev18 in forum Newbie
    Replies: 8
    Last Post: 15th August 2007, 20:16
  5. Exception handling in Qt 4.2.2
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2007, 09:47

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.