Hi, I make a simple aplication with a button, and I connected to a slot.
At first its looks easy, but then I realize that the pressed() signal arrives twice.

I debug the code and find inside the qwidget.cpp code :

Qt Code:
  1. switch (event->type()) {
  2. case QEvent::MouseMove:
  3. mouseMoveEvent((QMouseEvent*)event);
  4. break;
  5.  
  6. case QEvent::MouseButtonPress:
  7. // Don't reset input context here. Whether reset or not is
  8. // a responsibility of input method. reset() will be
  9. // called by mouseHandler() of input method if necessary
  10. // via mousePressEvent() of text widgets.
  11. #if 0
  12. resetInputContext();
  13. #endif
  14. mousePressEvent((QMouseEvent*)event);
  15. break;
  16.  
  17. case QEvent::MouseButtonRelease:
  18. mouseReleaseEvent((QMouseEvent*)event);
To copy to clipboard, switch view to plain text mode 

the first signal is emited after mousePressEvent event and the second after mouseMoveEvent
Why MoveEvent throw a pressed() signal?

I Add the call stack of the two cases

Qt Code:
  1. Case 1: mousePressEvent
  2.  
  3. QtCored4.dll!QMetaObject::metacall(QObject* object = 0x01b054a0, QMetaObject::Call
  4. QtCored4.dll!QMetaObject::activate(QObject* sender = 0x01ae6cb0, QMetaObject* m =
  5. QtGuid4.dll!QAbstractButton::pressed(void) Line: 192, Byte Offsets: 0x2c C+
  6. QtGuid4.dll!QAbstractButtonPrivate::emitPressed(void) Line: 562, Byte Offsets: 0x4
  7. QtGuid4.dll!QAbstractButton::mousePressEvent(QMouseEvent* e = 0x1ba7d05c) Line: 10
  8. QtGuid4.dll!QWidget::event(QEvent* event = 0x1ba7d05c) Line: 8197, Byte Offsets: 0
  9. QtGuid4.dll!QAbstractButton::event(QEvent* e = 0x1ba7d05c) Line: 1080, Byte Offset
  10. QtGuid4.dll!QPushButton::event(QEvent* e = 0x1ba7d05c) Line: 683, Byte Offsets: 0x
  11. QtGuid4.dll!QApplicationPrivate::notify_helper(QObject* receiver = 0x01ae6cb0, QEv
  12. QtGuid4.dll!QApplication::notify(QObject* receiver = 0x01ae6cb0, QEvent* e = 0x1ba
  13.  
  14. Case 2: mouseMoveEvent
  15.  
  16. QtCored4.dll!QMetaObject::metacall(QObject* object = 0x01b054a0, QMetaObject::Call
  17. QtCored4.dll!QMetaObject::activate(QObject* sender = 0x01ae6cb0, QMetaObject* m =
  18. QtGuid4.dll!QAbstractButton::pressed(void) Line: 192, Byte Offsets: 0x2c C+
  19. QtGuid4.dll!QAbstractButtonPrivate::emitPressed(void) Line: 562, Byte Offsets: 0x4
  20. QtGuid4.dll!QAbstractButton::mouseMoveEvent(QMouseEvent* e = 0x1ba7d05c) Line: 114
  21. QtGuid4.dll!QWidget::event(QEvent* event = 0x1ba7d05c) Line: 8186, Byte Offsets: 0
  22. QtGuid4.dll!QAbstractButton::event(QEvent* e = 0x1ba7d05c) Line: 1080, Byte Offset
  23. QtGuid4.dll!QPushButton::event(QEvent* e = 0x1ba7d05c) Line: 683, Byte Offsets: 0x
  24. QtGuid4.dll!QApplicationPrivate::notify_helper(QObject* receiver = 0x01ae6cb0, QEv
  25. QtGuid4.dll!QApplication::notify(QObject* receiver = 0x01ae6cb0, QEvent* e = 0x1ba
To copy to clipboard, switch view to plain text mode 

( Sorry I limitate the lines longitud to help to read it if same one need all the line don't hesitate to ask )

Is it a Qt bug?

Regards,

Juan Manuel