Results 1 to 2 of 2

Thread: mouseMoveEvent(QMouseEvent* event), event->button()

  1. #1
    Join Date
    Dec 2008
    Location
    Irkutsk, Russia
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default mouseMoveEvent(QMouseEvent* event), event->button()

    I realise drag&drop actions on QTableView. My reimplemented mouseMoveEvent() looks so:

    Qt Code:
    1. void
    2. MyClass::mouseMoveEvent(QMouseMove* event)
    3. {
    4. qDebug() << event->button();
    5. if (event->button() == Qt::LeftButton) {
    6. int distance = (event->pos() - fPressPos).manhattanLength();
    7. if (distance > QApplication::startDragDistance()) {
    8. startDrag();
    9. }
    10. }
    11. QTableView::mouseMoveEvent(event);
    12. }
    To copy to clipboard, switch view to plain text mode 

    I execute my application and tried to move mouse with pressed left button above my widget. In debug messages I see 0. And function did not enter first condition. So move event called, but QMouseEvent not contains information about buttons pressed. I have not idea why it happening.

  2. #2
    Join Date
    Dec 2008
    Location
    Irkutsk, Russia
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: mouseMoveEvent(QMouseEvent* event), event->button()

    Oops, I solved my trouble myself... The condition must looks like this:

    Qt Code:
    1. if (event->buttons() & Qt::LeftButton) {
    2. // code here
    3. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Event propagation direction
    By spraff in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2008, 21:03
  2. Qt event queue overloading?
    By gct in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2008, 18:39
  3. Replies: 1
    Last Post: 16th October 2007, 22:41
  4. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05
  5. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55

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.