Hello,
all is in the title.
I have subclassed a QGraphicsPolygonItem,
- when ItemIsMovable==True, my context menu appears, as expected.
- if i disable the flag, context menu does not appear anymore.
My program is quite long and complicated, but here are the lines involved :
def __init__(self, **dump):
[...]
super(NGraphicsCloisonItem, self).__init__(self.model.qpolygon, parent=parentitem)
[...]
self.setVisible(True)
[...]
class NGraphicsCloisonItem(QtGui.QGraphicsPolygonItem):
Type = QtGui.QGraphicsItem.UserType + 6
def __init__(self, **dump):
[...]
super(NGraphicsCloisonItem, self).__init__(self.model.qpolygon, parent=parentitem)
[...]
self.setVisible(True)
self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, False)
self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable, True)
[...]
To copy to clipboard, switch view to plain text mode
and in the scene :
def contextMenuEvent(self,event):
menu = someMenuThatWorksWhenMovable
for action in someListOfActions :
for view in self.views():
view.addAction(action)
menu.exec_(event.screenPos())
def contextMenuEvent(self,event):
menu = someMenuThatWorksWhenMovable
for action in someListOfActions :
for view in self.views():
view.addAction(action)
menu.exec_(event.screenPos())
To copy to clipboard, switch view to plain text mode
Thank you for your answer.
Bookmarks