tags:

views:

502

answers:

4

Hi,

I need to know what was the mouse button clicked when a QListView::clicked signal is emitted.

How can I know the button.

Regards

+2  A: 

Hi, try to implements a new class inherit form QListView and re-implement: void QAbstractItemView::mousePressEvent ( QMouseEvent * event ) [virtual protected].

I hope it's usefull. Salu2

Miguel Angel
I have done it, but after the handling of the new created signal the right mouse click is send too to the QDockWidget.
xgoan
+1  A: 

Salu2 is correct, also if you are just after a context menu (on right click) you could reimplement QWidget::contextMenuEvent

Phil Hannent
+1  A: 

If you are not interested in subclassing, you can also create an event filter class and install that filter onto the object in which you want to listen to (in this case, the QListView).

For more information look at QObject::installEventFilter().

swongu
+1  A: 

How about QApplication::mousebuttons()? That is what the documentation suggests to do to find the button.

Karl Napf
How to use QApplication::mousebuttons()? I have the same problem. I try to use this function, however, it didn't return Qt::RightButton or Qt::LeftButton correctly ><.
Claire Huang