PDA

View Full Version : How to add right click actions?



hakermania
16th November 2010, 19:46
Hello all, I want to have a On_item_right_clicked action on a listwidget but unfortunately there is no such slot. Can you show me the right way of materializing this? :rolleyes: :rolleyes:
For instance, I want when to right click on an Item of the listwidget to have a menu with some options and then these options to be connected with some other slot that guides to a void function:rolleyes:

hakermania
16th November 2010, 23:39
Ok, i've found a kind of solution but i haven't understand very well..
I feel that I'm saying a simple thing: I am using designer. I do right click on the listwidget and I go to slot-> customContextMenuRequested(QPoint pos);What code should I place there so to have a menu on right click?

ChrisW67
17th November 2010, 07:31
A few calls to QWidget::addAction() and then QWidget::setContextMenuPolicy() with Qt::ActionsContextMenu. No need to override the context menu event handler unless you have something more complicated to do there.