def contextMenuEvent(self, event: QtGui.QContextMenuEvent) -> None: column = self.currentColumn() if column % 3 != 2: row = self.currentRow() menu = CellMenu(self, row, column) menu_position = event.pos() self._open_context_menu(menu, menu_position)
def contextMenuEvent(self, event: QtGui.QContextMenuEvent): index = self.indexAt( event.pos() ) # fixme: DeprecationWarning: Function: 'pos() const' is marked as deprecated, please check the documentation for more information. model = index.model() if model: # click on item menu = QtWidgets.QMenu(self) if model.isDir(index): menu.addAction(self.action_open) menu.addAction(self.action_open_new) else: menu.addAction(self.action_open_default) menu.exec(event.globalPos()) else: # click on empty space pass
def contextMenuEvent(self, event: QContextMenuEvent): """Override Qt method to pop up a list of statuses and change visible of status. """ menu = AMenu(self) for text, is_checked in self._checked_dict.items(): action = create_action( parent=self, text=text, is_checkable=True, is_checked=is_checked, ) menu.addAction(action) # type: ignore # Display popup menu on places of right-clicked. selected_action = menu.exec_(self.mapToGlobal( event.pos())) # type: ignore if selected_action is not None: action_text = selected_action.text() is_check = self._checked_dict[action_text] self._checked_dict[action_text] = not is_check if is_check: self._status_dict[action_text].hide() else: self._status_dict[action_text].show()