當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。