QListWidget 是继承 QWidget 的, 所以 QListWidget 是有右键菜单的,
从文档上可以找到 QWidget 上有以下两个与右键菜单有关的函数:
Qt.ContextMenuPolicy
self)
self, Qt.ContextMenuPolicy
policy)
Qt.ContextMenuPolicy 是一个枚举类型:
Constant
Value
Description
Qt.NoContextMenu
0
the widget does not feature a context menu, context menu handling is deferred to the widget's parent.
Qt.PreventContextMenu
4
the widget does not feature a context menu, and in contrast to NoContextMenu, the handling is not deferred to the widget's parent. This means that all right mouse button events are guaranteed to be delivered to the widget itself through mousePressEvent(), and mouseReleaseEvent().
Qt.DefaultContextMenu
1
the widget's QWidget.contextMenuEvent() handler is called.
Qt.ActionsContextMenu
2
the widget displays