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. In QMenu, the mouse hover cannot be set
Forum Updated to NodeBB v4.3 + New Features

In QMenu, the mouse hover cannot be set

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 147 Views
  • 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.
  • L Offline
    L Offline
    LuoMeng
    wrote on 18 Mar 2025, 02:42 last edited by
    #1

    Here is a test case:

    from PyQt6.QtWidgets import QApplication, QSystemTrayIcon, QMenu
    from PyQt6.QtGui import QIcon, QAction
    
    
    class TrayIconApp:
        def __init__(self):
            self.app = QApplication([])
    
            self.tray_icon = QSystemTrayIcon()
            self.tray_icon.setIcon(QIcon("../Pets/MengJi_pro.png")) 
    
            self.tray_menu = QMenu()
    
            self.tray_menu.setStyleSheet("""
                QMenu::item {
                    padding: 5px 20px;
                    text-align: center;
                    background-color: white;
                    color: black;
                }
                QMenu::item:hover {
                    background-color: #0078d7;
                    color: white;
                }
                QMenu::item:pressed {
                    background-color: #005bb5;
                    color: white;
                }
            """)
    
            self.show_action = QAction("Show", self.tray_menu)
            self.exit_action = QAction("Exit", self.tray_menu)
            self.tray_menu.addAction(self.show_action)
            self.tray_menu.addAction(self.exit_action)
    
            self.tray_icon.setContextMenu(self.tray_menu)
    
            self.tray_icon.show()
    
            self.app.exec()
    
    
    if __name__ == "__main__":
        app = TrayIconApp()
    

    After I run the code, right click the icon and hover the mouse on the widget, nothing changes in color. I think this is a bug.

    1 Reply Last reply
    0

    1/1

    18 Mar 2025, 02:42

    • Login

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