Slot mouse event: right click / middle click... how to catch this ?
-
wrote on 5 Jan 2015, 03:54 last edited by
Hi,
I would like to be able to catch events like right and middle click mouse... but in the list of slot event in the QtDesigner, i can not see any option for do it. Also, search in the Qt doc is a big pain (except maybe if you know allready all the Qt code... but at this point, you not need the doc).Also, for now i need to use it inside two QTreeView (i have my own Model create for one, and an other one use QStandardItemModel). i would like to use it on a row (for exemple, right click on a row open a menu... by this way i could delete the row, and all the childs of the row).
Same for middle click but on an item in the treeview call an other menu.Qt can do it easy ? and how to find usable/readable informations to learn this ? (QT-5.3.2 with C++)
thanks for try to help.
-
Hope you got a chance to look at how to handle mouse events in Qt. Please look at QWidget virtual functions like mousePressEvent(....), mouseMoveEvent(...) etc. This should help you. You can't get these in Qt Designer as slots. You need to override these methods and handle these events.
-
wrote on 5 Jan 2015, 04:07 last edited by
Ok thanks, i just read on QMouseEvent. surprise that this part of doc seems to be clear.
has i can understand, i can enable it for the widget (i think QTreeView is a widget...) and reicept datas about the button clicked (and then create a condition test around this), and the x,y position inside the widget... with this position, i can search the item with indexAt(Qpos) inside my model.
right ?
-
ok. Just look at Model view programming documentation in Qt Assistant, look a the QTableView class which is QWidget. Look at SelectionModel class etc. All this together may help you on what you are trying to do.
-
wrote on 5 Jan 2015, 07:07 last edited by
ok fine, this works perfectly.
I try now to open a menu after catch it... i would post about this because it is not the same subject now.Thanks again.
-
wrote on 5 Jan 2015, 09:15 last edited by
Also check: "virtual void contextMenuEvent(QContextMenuEvent * event)":http://doc-snapshot.qt-project.org/qt5-5.4/qwidget.html
Greetings
Nando[quote author="jerome_isAviable?" date="1420441651"]ok fine, this works perfectly.
I try now to open a menu after catch it... i would post about this because it is not the same subject now.Thanks again.[/quote]
3/6