Jesus Fernandez
Jesus Fernandez

Reputation: 1290

QListView clicked mouse button

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

How can I know the button.

Upvotes: 2

Views: 1898

Answers (4)

Miguel Angel
Miguel Angel

Reputation: 640

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

Upvotes: 2

Karl Napf
Karl Napf

Reputation: 106

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

Upvotes: 1

swongu
swongu

Reputation: 2299

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().

Upvotes: 1

Phil Hannent
Phil Hannent

Reputation: 12307

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

Upvotes: 1

Related Questions