当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QContextMenuEvent方法代码示例

本文整理汇总了Python中PyQt5.QtGui.QContextMenuEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QContextMenuEvent方法的具体用法?Python QtGui.QContextMenuEvent怎么用?Python QtGui.QContextMenuEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtGui的用法示例。


在下文中一共展示了QtGui.QContextMenuEvent方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: contextMenuEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def contextMenuEvent(self, event: QContextMenuEvent) -> None:
        col = self.columnAt(event.pos().x())
        row = self.rowAt(event.pos().y())
        if col == 3:
            item = self.item(row, col)
            vtype = item.value_type
            if vtype != "unknown":
                menu = QMenu(self)
                as_int = QAction("repr as int", self)
                as_int.triggered.connect(lambda: self.repr_as_int(row, col))
                as_hex = QAction("repr as hex", self)
                as_hex.triggered.connect(lambda: self.repr_as_hex(row, col))
                as_flt = QAction("repr as floating", self)
                as_flt.triggered.connect(lambda: self.repr_as_floating(row, col))
                as_str = QAction("repr as str", self)
                as_str.triggered.connect(lambda: self.repr_as_str(row, col))
                as_bys = QAction("repr as bytes", self)
                as_bys.triggered.connect(lambda: self.repr_as_bytes(row, col))
                menu.addAction(as_int)
                menu.addAction(as_hex)
                menu.addAction(as_flt)
                menu.addAction(as_str)
                menu.addAction(as_bys)
                menu.popup(QCursor.pos()) 
开发者ID:hase-project,项目名称:hase,代码行数:26,代码来源:viewtable.py

示例2: event

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def event(self, e):
        if not isinstance(e, (
                QtCore.QEvent,
                QtCore.QChildEvent,
                QtCore.QDynamicPropertyChangeEvent,
                QtGui.QPaintEvent,
                QtGui.QHoverEvent,
                QtGui.QMoveEvent,
                QtGui.QEnterEvent,
                QtGui.QResizeEvent,
                QtGui.QShowEvent,
                QtGui.QPlatformSurfaceEvent,
                QtGui.QWindowStateChangeEvent,
                QtGui.QKeyEvent,
                QtGui.QWheelEvent,
                QtGui.QMouseEvent,
                QtGui.QFocusEvent,
                QtGui.QHelpEvent,
                QtGui.QHideEvent,
                QtGui.QCloseEvent,
                QtGui.QInputMethodQueryEvent,
                QtGui.QContextMenuEvent,
                )):
            log().warning("unknown event: %r %r", e.type(), e)
        return super().event(e) 
开发者ID:frans-fuerst,项目名称:track,代码行数:27,代码来源:mainwindow.py

示例3: contextMenuEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def contextMenuEvent(self, *args, **kwargs):
        ev = args[0]
        assert isinstance(ev, QContextMenuEvent)

        point = ev.pos()
        rows = self.selectionModel().selectedRows()
        self._destination_menu_action.setEnabled(False)

        if rows:
            if len(rows) == 1 and self.model().isDir(rows[0]):
                self._destination_menu_action.setEnabled(True)

            self.context_menu.exec(self.mapToGlobal(point)) 
开发者ID:BetaRavener,项目名称:uPyLoader,代码行数:15,代码来源:transfer_tree_view.py

示例4: contextMenuEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def contextMenuEvent(self, evt: QContextMenuEvent) -> None:
        menu = QMenu()
        menu.triggered.connect(self.context_menu_actions_handler)
        index: QModelIndex = self.indexAt(evt.pos())
        if index.isValid():
            icon: QIcon = GUIUtilities.get_icon('delete_label.png')
            action = menu.addAction(icon, self.CTX_MENU_DELETE_LABEL)
            action.setData(index)
        else:
            icon: QIcon = GUIUtilities.get_icon('new_label.png')
            menu.addAction(icon, self.CTX_MENU_ADD_LABEL)
        menu.exec_(self.mapToGlobal(evt.pos())) 
开发者ID:haruiz,项目名称:CvStudio,代码行数:14,代码来源:labels_tableview.py

示例5: contextMenuEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def contextMenuEvent(self, evt: QContextMenuEvent) -> None:
        index: QModelIndex = self.indexAt(evt.pos())
        actions = []
        if index.isValid():
            node: CustomNode = index.internalPointer()
            index: QModelIndex = self.indexAt(evt.pos())
            menu = QMenu()
            menu.triggered.connect(self.context_menu_actions_handler)
            if node.level == 1:
                actions = [
                    QAction(gui.get_icon('new_folder.png'), self.CTX_MENU_ADD_REPOSITORY_ACTION)
                ]
            elif node.level == 2:
                actions = [
                    QAction(gui.get_icon('delete.png'), self.CTX_MENU_DELETE_REPO_ACTION),
                    QAction(gui.get_icon('refresh.png'), self.CTX_MENU_UPDATE_REPO_ACTION)
                ]
            elif node.level == 3:
                actions = [
                    QAction(gui.get_icon('robotic-hand.png'), self.CTX_MENU_AUTO_LABEL_ACTION)
                ]
            if actions:
                for act in actions:
                    act.setData(index)
                    menu.addAction(act)
            menu.exec_(self.mapToGlobal(evt.pos())) 
开发者ID:haruiz,项目名称:CvStudio,代码行数:28,代码来源:models_treeview.py

示例6: contextMenuEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def contextMenuEvent(self, event: QContextMenuEvent):
        pass 
开发者ID:jopohl,项目名称:urh,代码行数:4,代码来源:CompareFrameController.py

示例7: contextMenuEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def contextMenuEvent(self, event: QContextMenuEvent):
        self.context_menu_pos = event.pos()
        menu = self.create_context_menu()
        menu.exec(self.mapToGlobal(event.pos()))
        self.context_menu_pos = None 
开发者ID:jopohl,项目名称:urh,代码行数:7,代码来源:ProtocolTreeView.py

示例8: contextMenuEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def contextMenuEvent(self, event: QContextMenuEvent):
        self.create_context_menu().exec_(self.mapToGlobal(event.pos())) 
开发者ID:jopohl,项目名称:urh,代码行数:4,代码来源:ParticipantTableView.py

示例9: contextMenuEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def contextMenuEvent(self, event: QContextMenuEvent):
        menu = self.create_context_menu()
        menu.exec_(self.mapToGlobal(event.pos())) 
开发者ID:jopohl,项目名称:urh,代码行数:5,代码来源:TextEditProtocolView.py

示例10: contextMenuEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def contextMenuEvent(self, event: QContextMenuEvent):
        self.context_menu_pos = event.pos()
        menu = self.create_context_menu()
        menu.exec(self.mapToGlobal(self.context_menu_pos))
        self.context_menu_pos = None 
开发者ID:jopohl,项目名称:urh,代码行数:7,代码来源:GeneratorListView.py

示例11: contextMenuEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def contextMenuEvent(self, event: QContextMenuEvent):
        self.context_menu_position = event.pos()
        menu = self.create_context_menu()
        menu.exec_(self.mapToGlobal(event.pos()))
        self.context_menu_position = None 
开发者ID:jopohl,项目名称:urh,代码行数:7,代码来源:ZoomableGraphicView.py

示例12: contextMenuEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def contextMenuEvent(self, event: QContextMenuEvent):
        self.context_menu_pos = event.pos()
        menu = self.create_context_menu()
        menu.exec_(self.mapToGlobal(event.pos()))
        self.context_menu_pos = None 
开发者ID:jopohl,项目名称:urh,代码行数:7,代码来源:ListWidget.py

示例13: eventFilter

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QContextMenuEvent [as 别名]
def eventFilter(self, obj, ev):  # noqa: N802
        # Is it a QShowEvent on a QDialog named "Dialog"?
        if (
            ev.__class__ == ev,
            QShowEvent
            and obj.__class__ == QDialog
            and obj.windowTitle() == "About",
        ):
            # Find a child QGroupBox
            for groupBox in obj.children():
                if groupBox.__class__ == QGroupBox:
                    # Find a child QLabel with an icon
                    for label in groupBox.children():
                        if isinstance(label, QLabel) and label.pixmap():
                            self._replace_icon(label)

        # Is it a QContextMenuEvent on a QWidget?
        if isinstance(obj, QWidget) and isinstance(ev, QContextMenuEvent):
            # Find a parent titled "IDA View"
            parent = obj
            while parent:
                if parent.windowTitle().startswith("IDA View"):
                    # Intercept the next context menu
                    self._intercept = True
                parent = parent.parent()

        # Is it a QShowEvent on a QMenu?
        if isinstance(obj, QMenu) and isinstance(ev, QShowEvent):
            # Should we intercept?
            if self._intercept:
                self._insert_menu(obj)
                self._intercept = False

        # Is it a ToolTip event on a QWidget with a parent?
        if (
            ev.type() == QEvent.ToolTip
            and obj.__class__ == QWidget
            and obj.parent()
        ):
            table_view = obj.parent()
            # Is it a QTableView with a parent?
            if table_view.__class__ == QTableView and table_view.parent():
                func_window = table_view.parent()
                # Is it a QWidget titled "Functions window"?
                if (
                    func_window.__class__ == QWidget
                    and func_window.windowTitle() == "Functions window"
                ):
                    self._set_tooltip(obj, ev)

        return False 
开发者ID:IDArlingTeam,项目名称:IDArling,代码行数:53,代码来源:filter.py


注:本文中的PyQt5.QtGui.QContextMenuEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。