src/gui/widgets/qabstractbutton.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
--- a/src/gui/widgets/qabstractbutton.cpp	Tue Jan 26 12:42:25 2010 +0200
+++ b/src/gui/widgets/qabstractbutton.cpp	Tue Feb 02 00:43:10 2010 +0200
@@ -165,7 +165,7 @@
     shortcutId(0),
 #endif
     checkable(false), checked(false), autoRepeat(false), autoExclusive(false),
-    down(false), blockRefresh(false),
+    down(false), blockRefresh(false), pressed(false),
 #ifndef QT_NO_BUTTONGROUP
     group(0),
 #endif
@@ -1090,6 +1090,7 @@
     }
     if (hitButton(e->pos())) {
         setDown(true);
+        d->pressed = true;
         repaint(); //flush paint event before invoking potentially expensive operation
         QApplication::flush();
         d->emitPressed();
@@ -1103,6 +1104,8 @@
 void QAbstractButton::mouseReleaseEvent(QMouseEvent *e)
 {
     Q_D(QAbstractButton);
+    d->pressed = false;
+
     if (e->button() != Qt::LeftButton) {
         e->ignore();
         return;
@@ -1127,7 +1130,7 @@
 void QAbstractButton::mouseMoveEvent(QMouseEvent *e)
 {
     Q_D(QAbstractButton);
-    if (!(e->buttons() & Qt::LeftButton)) {
+    if (!(e->buttons() & Qt::LeftButton) || !d->pressed) {
         e->ignore();
         return;
     }