<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[PyQt6: Popup QMainWindow sometimes ignoring (&quot;missing&quot;) clicks even if opened and activated]]></title><description><![CDATA[<p dir="auto">I’m building a macOS menu bar extra (a.k.a. system tray) app using PyQt6. When clicking the menu bar icon, a popup window appears, which is a QMainWindow with the <code>Qt.WindowType.Popup</code> window flag set.</p>
<p dir="auto">I’m noticing sporadic issues where the popup window doesn't respond to clicks even though it's open. Sometimes, clicking on a QPushButton inside the popup, or an action on the QMenu, causes it to close abruptly without the <code>clicked</code> signal being invoked on the button or the <code>triggered</code> action on a menu item (i.e., clicks are sometimes being “missed”). The popup window contains a QTreeWidget which I’ve styled with QSS so that hovering over a QTreeWidgetItem will cause it to be highlighted; sometimes the highlight doesn’t appear, suggesting that the open popup window is ignoring user interaction. Switching between windows from other open applications and then clicking the menu bar icon for my app sometimes causes the issue to occur.</p>
<p dir="auto">The issue is reproducible on macOS 15 Sequoia and macOS 26 Tahoe, using a mouse (on a Mac Mini) and a trackpad (on a MacBook Air). I'm using PyQt6 version 6.11.0, and Python 3.14.4. The app is distributed as a PyInstaller build, but I've noticed this issue sometimes occurring on my dev machine, where the app is executed directly from the Python interpreter.</p>
<p dir="auto">I tried calling the <code>activateWindow()</code> method on the QMainWindow object for the popup window, as well as calling <code>grabMouse()</code> (and <code>releaseMouse()</code> in the overridden method <code>closeEvent()</code>). I also ensured that the widgets within the popup window have its <code>self</code> object passed to their constructors. But the issue is still occurring.</p>
<p dir="auto">What should I be doing to ensure that the popup window is consistently capturing mouse input when it’s opened? What gotchas and caveats that I missed that could be causing this issue?</p>
]]></description><link>https://forum.qt.io/topic/164883/pyqt6-popup-qmainwindow-sometimes-ignoring-missing-clicks-even-if-opened-and-activated</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Jul 2026 04:56:59 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164883.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Jul 2026 20:10:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to PyQt6: Popup QMainWindow sometimes ignoring (&quot;missing&quot;) clicks even if opened and activated on Sun, 19 Jul 2026 01:08:28 GMT]]></title><description><![CDATA[<p dir="auto">Just in case it makes a difference, the issue also occurs if running as a PyInstaller-packaged app. I've built the above demo into a macOS app bundle using PyInstaller and put the resulting DMG redistributable, as well as the source files for the above demo and the build scripts, into this GitHub repo: <a href="https://github.com/aecreations/PyQtPopupDemo" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/aecreations/PyQtPopupDemo</a></p>
<p dir="auto">The DMG installer can be downloaded from here: <a href="https://github.com/aecreations/PyQtPopupDemo/releases/tag/0.0.2" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/aecreations/PyQtPopupDemo/releases/tag/0.0.2</a>. It has been signed using my Apple Developer certificate and is notarized by Apple.</p>
]]></description><link>https://forum.qt.io/post/839220</link><guid isPermaLink="true">https://forum.qt.io/post/839220</guid><dc:creator><![CDATA[1st-alex]]></dc:creator><pubDate>Sun, 19 Jul 2026 01:08:28 GMT</pubDate></item><item><title><![CDATA[Reply to PyQt6: Popup QMainWindow sometimes ignoring (&quot;missing&quot;) clicks even if opened and activated on Sun, 19 Jul 2026 00:12:27 GMT]]></title><description><![CDATA[<p dir="auto">The issue happens approximately once every 10 or so clicks. It is definitely very noticeable if using a trackpad on a Mac laptop. I've been able to reproduce this on a MacBook Air (M4, 2025, running macOS 26 Tahoe).</p>
<p dir="auto">As for the use of QMainWindow - this is what I'm currently using in my actual app, which was changed from a QWidget after reading somewhere about tap gestures requiring a QMainWindow, though that change hasn't made a difference (and so I might as well change it back to QWidget).</p>
]]></description><link>https://forum.qt.io/post/839219</link><guid isPermaLink="true">https://forum.qt.io/post/839219</guid><dc:creator><![CDATA[1st-alex]]></dc:creator><pubDate>Sun, 19 Jul 2026 00:12:27 GMT</pubDate></item><item><title><![CDATA[Reply to PyQt6: Popup QMainWindow sometimes ignoring (&quot;missing&quot;) clicks even if opened and activated on Sat, 18 Jul 2026 19:08:29 GMT]]></title><description><![CDATA[<p dir="auto">Can you give me an estimation of how sporadic it is ? I tried several times on macOS 15.7.7 and it worked pretty nicely.<br />
One thing that is not clear is why are you using a full QMainWindow for your popup rather than just a QWidget ?</p>
]]></description><link>https://forum.qt.io/post/839215</link><guid isPermaLink="true">https://forum.qt.io/post/839215</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sat, 18 Jul 2026 19:08:29 GMT</pubDate></item><item><title><![CDATA[Reply to PyQt6: Popup QMainWindow sometimes ignoring (&quot;missing&quot;) clicks even if opened and activated on Thu, 16 Jul 2026 21:35:45 GMT]]></title><description><![CDATA[<p dir="auto">Issue is reproducible in PySide6. Below is the source code for a demo app; it should be executed on macOS 13 Ventura or newer. Also included is an image file to use as the menu bar extra icon.</p>
<p dir="auto">Again, this is a sporadic issue, so you may have to try it a few times to cause the issue to occur. Switching between windows from other open applications and then clicking the menu bar icon for my app may cause it to happen.</p>
<p dir="auto"><strong><code>demo.py:</code></strong></p>
<pre><code>import sys
from PySide6.QtWidgets import QApplication
from SamplePopupWnd import SamplePopupWnd

mainwnd = None

def main():
    global mainwnd
    app = QApplication(sys.argv)
    app.setQuitOnLastWindowClosed(False)
    mainwnd = SamplePopupWnd()
    sys.exit(app.exec())

main()
</code></pre>
<p dir="auto"><strong><code>SamplePopupWnd.py:</code></strong></p>
<pre><code>import sys
from PySide6.QtCore import Qt, QPoint, QSize
from PySide6.QtGui import QIcon, QAction, QGuiApplication
from PySide6.QtWidgets import (QWidget, QMenu, QSystemTrayIcon, QHBoxLayout, QPushButton,
    QMessageBox, QMainWindow)

class SamplePopupWnd(QMainWindow):
    def __init__(self):
        super().__init__()
        self.popupwidth = 300
        self.popupheight = 400

        # Menu bar extra icon.
        icon = self.getSystemTrayIcon()
        self.systray = QSystemTrayIcon()
        self.systray.setIcon(icon)
        self.systray.setVisible(True)
        self.systray.activated.connect(self.togglePopup)

        self.button = QPushButton("button", self)
        self.button.clicked.connect(self.showButtonMessage)

        # Actions for a menu that is opened by a menu button
        self.settings = QAction("settings", self)
        self.settings.triggered.connect(self.showMenuMessage)
        self.about_act = QAction("about", self)
        self.about_act.triggered.connect(self.aboutActionSelected)
        self.quit_act = QAction("quit", self)
        self.quit_act.triggered.connect(self.quitActionSelected)

        self.menu = QMenu(self)
        self.menu.addAction(self.settings)
        self.menu.addAction(self.about_act)
        self.menu.addSeparator()
        self.menu.addAction(self.quit_act)
        self.menubutton = QPushButton("≡ menu", self)
        self.menubutton.setMenu(self.menu)

        hbox = QHBoxLayout(self)
        hbox.addWidget(self.button)
        hbox.addStretch(2)
        hbox.addWidget(self.menubutton)

        # Add to a QWidget that is styled with rounded corners.
        self.popup = QWidget(self)
        self.popup.setObjectName("popup")
        self.popup.resize(QSize(self.popupwidth, self.popupheight))
        self.popup.setLayout(hbox)

        self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True)
        self.setWindowFlags(Qt.WindowType.Popup)
        self.setGeometry(200, 100, self.popupwidth, self.popupheight)
        self.setStyleSheet("""
            #popup {
                border-radius: 16px;
                background-color: #fefefe;
            }
        """)

    def showButtonMessage(self):
        QMessageBox.information(self, "demo", "the Button was clicked!", QMessageBox.StandardButton.Ok)

    def showMenuMessage(self):
        QMessageBox.information(self, "demo", "the Menu Action was clicked!", QMessageBox.StandardButton.Ok)

    def aboutActionSelected(self):
        QMessageBox.about(self, "about", "qt for python popup demo 1.0")

    def quitActionSelected(self):
        sys.exit()

    def getSystemTrayIcon(self):
        icon = QIcon("systray.png")
        return icon

    def togglePopup(self, reason):
        # Handle click on system tray icon.
        if reason == QSystemTrayIcon.ActivationReason.Trigger:
            if self.isVisible():
                self.close()
            else:
                self.openPopup()

    def openPopup(self):
        systray_geom = self.systray.geometry()
        x = systray_geom.x()
        y = 0 if systray_geom.y() &lt; 0 else systray_geom.y()
        currscreen = QGuiApplication.screenAt(QPoint(x, y))
        screen_avail_geom = currscreen.availableGeometry()
        top = screen_avail_geom.y()
        left1 = systray_geom.x()
        left2 = screen_avail_geom.width() - self.popupwidth

        # Align popup left coords with the system tray icon.
        left = left1 if left1 &lt; left2 else left2
        self.setGeometry(left, top, self.popupwidth, self.popupheight)
        self.show()
        self.activateWindow()
</code></pre>
<p dir="auto"><strong><code>systray.png:</code></strong><br />
<img src="https://ddgobkiprc33d.cloudfront.net/e6e07fc6-f9ab-4c8d-a897-6c14b1576101.png" alt="systray.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/839189</link><guid isPermaLink="true">https://forum.qt.io/post/839189</guid><dc:creator><![CDATA[1st-alex]]></dc:creator><pubDate>Thu, 16 Jul 2026 21:35:45 GMT</pubDate></item><item><title><![CDATA[Reply to PyQt6: Popup QMainWindow sometimes ignoring (&quot;missing&quot;) clicks even if opened and activated on Wed, 15 Jul 2026 19:00:51 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">Do you have the same issue if using PySide6 ?<br />
Can you share a minimal script that shows this issue ?</p>
]]></description><link>https://forum.qt.io/post/839174</link><guid isPermaLink="true">https://forum.qt.io/post/839174</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 15 Jul 2026 19:00:51 GMT</pubDate></item></channel></rss>