JuanMO
19th November 2010, 18:52
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 :
switch (event->type()) {
case QEvent::MouseMove:
mouseMoveEvent((QMouseEvent*)event);
break;
case QEvent::MouseButtonPress:
// Don't reset input context here. Whether reset or not is
// a responsibility of input method. reset() will be
// called by mouseHandler() of input method if necessary
// via mousePressEvent() of text widgets.
#if 0
resetInputContext();
#endif
mousePressEvent((QMouseEvent*)event);
break;
case QEvent::MouseButtonRelease:
mouseReleaseEvent((QMouseEvent*)event);
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
Case 1: mousePressEvent
QtCored4.dll!QMetaObject::metacall(QObject* object = 0x01b054a0, QMetaObject::Call
QtCored4.dll!QMetaObject::activate(QObject* sender = 0x01ae6cb0, QMetaObject* m =
QtGuid4.dll!QAbstractButton::pressed(void) Line: 192, Byte Offsets: 0x2c C+
QtGuid4.dll!QAbstractButtonPrivate::emitPressed(vo id) Line: 562, Byte Offsets: 0x4
QtGuid4.dll!QAbstractButton::mousePressEvent(QMous eEvent* e = 0x1ba7d05c) Line: 10
QtGuid4.dll!QWidget::event(QEvent* event = 0x1ba7d05c) Line: 8197, Byte Offsets: 0
QtGuid4.dll!QAbstractButton::event(QEvent* e = 0x1ba7d05c) Line: 1080, Byte Offset
QtGuid4.dll!QPushButton::event(QEvent* e = 0x1ba7d05c) Line: 683, Byte Offsets: 0x
QtGuid4.dll!QApplicationPrivate::notify_helper(QOb ject* receiver = 0x01ae6cb0, QEv
QtGuid4.dll!QApplication::notify(QObject* receiver = 0x01ae6cb0, QEvent* e = 0x1ba
Case 2: mouseMoveEvent
QtCored4.dll!QMetaObject::metacall(QObject* object = 0x01b054a0, QMetaObject::Call
QtCored4.dll!QMetaObject::activate(QObject* sender = 0x01ae6cb0, QMetaObject* m =
QtGuid4.dll!QAbstractButton::pressed(void) Line: 192, Byte Offsets: 0x2c C+
QtGuid4.dll!QAbstractButtonPrivate::emitPressed(vo id) Line: 562, Byte Offsets: 0x4
QtGuid4.dll!QAbstractButton::mouseMoveEvent(QMouse Event* e = 0x1ba7d05c) Line: 114
QtGuid4.dll!QWidget::event(QEvent* event = 0x1ba7d05c) Line: 8186, Byte Offsets: 0
QtGuid4.dll!QAbstractButton::event(QEvent* e = 0x1ba7d05c) Line: 1080, Byte Offset
QtGuid4.dll!QPushButton::event(QEvent* e = 0x1ba7d05c) Line: 683, Byte Offsets: 0x
QtGuid4.dll!QApplicationPrivate::notify_helper(QOb ject* receiver = 0x01ae6cb0, QEv
QtGuid4.dll!QApplication::notify(QObject* receiver = 0x01ae6cb0, QEvent* e = 0x1ba
( 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
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 :
switch (event->type()) {
case QEvent::MouseMove:
mouseMoveEvent((QMouseEvent*)event);
break;
case QEvent::MouseButtonPress:
// Don't reset input context here. Whether reset or not is
// a responsibility of input method. reset() will be
// called by mouseHandler() of input method if necessary
// via mousePressEvent() of text widgets.
#if 0
resetInputContext();
#endif
mousePressEvent((QMouseEvent*)event);
break;
case QEvent::MouseButtonRelease:
mouseReleaseEvent((QMouseEvent*)event);
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
Case 1: mousePressEvent
QtCored4.dll!QMetaObject::metacall(QObject* object = 0x01b054a0, QMetaObject::Call
QtCored4.dll!QMetaObject::activate(QObject* sender = 0x01ae6cb0, QMetaObject* m =
QtGuid4.dll!QAbstractButton::pressed(void) Line: 192, Byte Offsets: 0x2c C+
QtGuid4.dll!QAbstractButtonPrivate::emitPressed(vo id) Line: 562, Byte Offsets: 0x4
QtGuid4.dll!QAbstractButton::mousePressEvent(QMous eEvent* e = 0x1ba7d05c) Line: 10
QtGuid4.dll!QWidget::event(QEvent* event = 0x1ba7d05c) Line: 8197, Byte Offsets: 0
QtGuid4.dll!QAbstractButton::event(QEvent* e = 0x1ba7d05c) Line: 1080, Byte Offset
QtGuid4.dll!QPushButton::event(QEvent* e = 0x1ba7d05c) Line: 683, Byte Offsets: 0x
QtGuid4.dll!QApplicationPrivate::notify_helper(QOb ject* receiver = 0x01ae6cb0, QEv
QtGuid4.dll!QApplication::notify(QObject* receiver = 0x01ae6cb0, QEvent* e = 0x1ba
Case 2: mouseMoveEvent
QtCored4.dll!QMetaObject::metacall(QObject* object = 0x01b054a0, QMetaObject::Call
QtCored4.dll!QMetaObject::activate(QObject* sender = 0x01ae6cb0, QMetaObject* m =
QtGuid4.dll!QAbstractButton::pressed(void) Line: 192, Byte Offsets: 0x2c C+
QtGuid4.dll!QAbstractButtonPrivate::emitPressed(vo id) Line: 562, Byte Offsets: 0x4
QtGuid4.dll!QAbstractButton::mouseMoveEvent(QMouse Event* e = 0x1ba7d05c) Line: 114
QtGuid4.dll!QWidget::event(QEvent* event = 0x1ba7d05c) Line: 8186, Byte Offsets: 0
QtGuid4.dll!QAbstractButton::event(QEvent* e = 0x1ba7d05c) Line: 1080, Byte Offset
QtGuid4.dll!QPushButton::event(QEvent* e = 0x1ba7d05c) Line: 683, Byte Offsets: 0x
QtGuid4.dll!QApplicationPrivate::notify_helper(QOb ject* receiver = 0x01ae6cb0, QEv
QtGuid4.dll!QApplication::notify(QObject* receiver = 0x01ae6cb0, QEvent* e = 0x1ba
( 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