Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PyQt5 V5.15 Blocks context menu mouse event

PyQt5 V5.15 Blocks context menu mouse event

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 650 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bob_Walton_Apple
    wrote on last edited by
    #1

    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
    
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      Hi and welcome to devnet,

      Since it's an issue that looks like a regression in PyQt, you'll have to contact their author.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved