PyQt5 V5.15 Blocks context menu mouse event
Unsolved
Qt for Python
-
My problem is on an OSX previously developed application with a popup GUI, which was fully operational using PyQt5 V5.14.2 but stopped working from V5.15.0 onward.
This seems to be a PyQt bug which is blocking the context menu mouse signal when <setWindowModality(QtCore.Qt.ApplicationModal)>.
Right click brings up the context menu fine but selecting an item is blocked using the mouse.
Using the keyboard however to navigate and select works fine.I have no idea how to raise this as a bug in Qt or if anyone has a solution.
super(Config, self).__init__() self.setWindowModality(QtCore.Qt.ApplicationModal) # set for sole use # connect signals self.config_tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) # contextmenu policy self.config_tree.customContextMenuRequested.connect(self.menu_context_tree) # contextmenu signal
# ============================================================================ # = context menu # ============================================================================ def menu_context_tree(self, point): """Context menu options.""" # ------------------------------------------------- index = self.config_tree.indexAt(point) # info about the node selected if not index.isValid(): # check if valid return # not valid self.context_item = self.config_tree.itemAt(point) # item at point name = self.context_item.text(0) # the text of the node name = name.replace(' ', '').split(':') # split and remove whitespace if len(name) < 2: # check node list length return # branch selected try: # if menu exists if self.context_menu is not None: # menu is set self.context_menu = None # clear menu except Exception: # menu nonexistant pass self.context_menu = QMenu() # add context menu self.context_menu.addAction('Clear') # action to clear self.context_menu.triggered[QAction].connect(self.context_menu_action) # connect actions self.context_menu.exec_(self.config_tree.mapToGlobal(point)) # open menu # ============================================================================ # = context menu action # ============================================================================ def context_menu_action(self, action): """Context menu actions.""" # ------------------------------------------------- action_text = action.text() # action to be done genealogy = self.get_genealogy(self.context_item) # get items genealogy obj, owner, attribute = self.attr_find(genealogy) # find the attribute if action_text == 'Clear': # action is clear if isinstance(getattr(owner, attribute), bool): # key is bool self.context_item.setText(0, attribute + ': False') # change text setattr(owner, attribute, False) # set attribute else: if genealogy[0] == 'System': # modify system self.core_system_modified(obj, owner, attribute, '') # system modified else: self.context_item.setText(0, attribute + ': ') # change text setattr(owner, attribute, '') # set attribute obj.core.modified = True # set modified flag self.modified = True # global flag else: pass
-
Hi and welcome to devnet,
Since it's an issue that looks like a regression in PyQt, you'll have to contact their author.