Issue while overloading mouseReleaseEvent
Hi,
I have a strange issue between a QPushButton and my QToolBar. Basically, I override QPushButton to support right click events. When a user right click on the button, I overide mouseReleaseEvent and it emits a new custom signal. Another class deriving from QWidget connect this signal to a local slot. If this slot call a exec() method from a dialog, the dialog appear ok, but when the dialog close, a QMenu appear. This QMenu is the one generated by QToolBar when right clicking on the toolbar. As far as I'm concerned, the button and the toolbar are unrelated and the mouse was no where near the toolbar on the right click event.
So I can only assume that the right click event somehow propaged itself to the toolbar. If I change the exec() for a show() (and declare the dialog static), I don't see this problem.
I'm not sure if this description is clear enough... I will wait before posting a bunch of code.
Somebody has an idea?
Thanks!
Re: Issue while overloading mouseReleaseEvent
A minimal compileable program would be nice to do some tests. One thing came in my mind while reading. Try if it helps if you call QEvent::accept() in the event handler of your button.
Re: Issue while overloading mouseReleaseEvent
Hi, Thanks for your answer.
Accepting the event didn't change the behavior... I will work on a small example to recreate the problem.
1 Attachment(s)
Re: Issue while overloading mouseReleaseEvent
Here is a small example showing the problem... I'm attaching the files if somebody want to try it out. Since this example is so small, the problem must come for the derived class of QPushButton. Here is the code:
.h
Code:
#ifndef MULTI_MOUSE_CLICK_BUTTON_H
#define MULTI_MOUSE_CLICK_BUTTON_H
#include <QPushButton>
{
Q_OBJECT
public:
multiMouseClickButton
(QWidget* myParent
= 0);
signals:
void multiMouseLeftClicked();
void multiMouseMiddleClicked();
void multiMouseRightClicked();
protected:
private:
};
#endif
.cpp
Code:
#include <QMouseEvent>
#include "multiMouseClickButton.h"
multiMouseClickButton
::multiMouseClickButton(QWidget* myParent
) {
}
void multiMouseClickButton
::mousePressEvent(QMouseEvent* myEvent
) {
setDown( true );
}
void multiMouseClickButton
::mouseReleaseEvent(QMouseEvent* myEvent
) {
if(isDown())
{
switch(myEvent->button())
{
case Qt::LeftButton:
emit(multiMouseLeftClicked());
break;
case Qt::MidButton:
emit(multiMouseMiddleClicked());
break;
case Qt::RightButton:
emit(multiMouseRightClicked());
break;
default:
break;
}
}
setDown( false );
}
[ATTACH]Attachment 4288[/ATTACH]
Re: Issue while overloading mouseReleaseEvent
I'm sorry, but it works fine on my computer. (last Kubuntu and Qt 4.6.1)
right click on the button => dialogue appears => click there ok => dialogue disappears => NO context menu.
1 Attachment(s)
Re: Issue while overloading mouseReleaseEvent
I'm using Qt4.5 on mingw... Maybe it's a bug related to this specific config.
I will try with mingw/Qt4.6 and on a Linux box.
This what I'm getting after a right click with this code:
Attachment 4292
Re: Issue while overloading mouseReleaseEvent
It's working on Linux.
I tried on Qt4.6 mingw (the latest February 2010 release) and the issue is still there. Apparently this is a Qt bug on mingw.
I'm not sure where should I go from here... I guess I will report the problem.
Re: Issue while overloading mouseReleaseEvent
Quote:
Originally Posted by
Thierry
I'm not sure where should I go from here... I guess I will report the problem.
Strange. Yes, open a new ticket on the Qt Bug Tracker (if it does not exist a similar ticket.)