<?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[Tooltips and Menus on wrong screen]]></title><description><![CDATA[<p dir="auto">Qt 6 app on Windows PC with 2 screens.<br />
If the screens are identical, the result of QGuiApplication::screens().size() is 1. The geometry of this screen is the same as the second screen. Tooltips and popups/menus will appear on the wrong screen.<br />
If the screens are different, the result of QGuiApplication::screens().size() is 2 and both have the correct geometry.<br />
In the source code qwindowsscreen.cpp I found the following:</p>
<pre><code>static inline int indexOfMonitor(const WindowsScreenDataList &amp;screenData,
                                 const QString &amp;monitorName) {
    for (int i = 0; i &lt; screenData.size(); ++i)
        if (screenData.at(i).name == monitorName)
            return i;
    return -1;
}

/////

bool QWindowsScreenManager::handleScreenChanges()
{
    // Look for changed monitors, add new ones
    const WindowsScreenDataList newDataList = monitorData();
    const bool lockScreen = newDataList.size() == 1 &amp;&amp; (newDataList.front().flags &amp; QWindowsScreenData::LockScreen);
    bool primaryScreenChanged = false;
    for (const QWindowsScreenData &amp;newData : newDataList) {
        const int existingIndex = indexOfMonitor(m_screens, newData.name);
        if (existingIndex != -1) {
            m_screens.at(existingIndex)-&gt;handleChanges(newData);
            if (existingIndex == 0)
                primaryScreenChanged = true;
        } else {
            auto *newScreen = new QWindowsScreen(newData);
            m_screens.push_back(newScreen);
            QWindowSystemInterface::handleScreenAdded(newScreen,
                                                             newData.flags &amp; QWindowsScreenData::PrimaryScreen);
            qCDebug(lcQpaWindows) &lt;&lt; "New Monitor: " &lt;&lt; newData;
        }    // exists
    }        // for new screens.
    // Remove deleted ones but keep main monitors if we get only the
    // temporary lock screen to avoid window recreation (QTBUG-33062).
    if (!lockScreen) {
        for (int i = m_screens.size() - 1; i &gt;= 0; --i) {
            if (indexOfMonitor(newDataList, m_screens.at(i)-&gt;data().name) == -1)
                removeScreen(i);
        }     // for existing screens
    }     // not lock screen
    if (primaryScreenChanged) {
        if (auto theme = QWindowsTheme::instance()) // QTBUG-85734/Wine
            theme-&gt;refreshFonts();
    }
    return true;
}

////

void QWindowsScreen::handleChanges(const QWindowsScreenData &amp;newData) {
    m_data.physicalSizeMM = newData.physicalSizeMM;

    if (m_data.hMonitor != newData.hMonitor) {
        qCDebug(lcQpaWindows) &lt;&lt; "Monitor" &lt;&lt; m_data.name
            &lt;&lt; "has had its hMonitor handle changed from"
            &lt;&lt; m_data.hMonitor &lt;&lt; "to" &lt;&lt; newData.hMonitor;
        m_data.hMonitor = newData.hMonitor;
    }

    // QGuiApplicationPrivate::processScreenGeometryChange() checks and emits
    // DPI and orientation as well, so, assign new values and emit DPI first.
    const bool geometryChanged = m_data.geometry != newData.geometry
        || m_data.availableGeometry != newData.availableGeometry;
    const bool dpiChanged = !qFuzzyCompare(m_data.dpi.first, newData.dpi.first)
        || !qFuzzyCompare(m_data.dpi.second, newData.dpi.second);
    const bool orientationChanged = m_data.orientation != newData.orientation;
    m_data.dpi = newData.dpi;
    m_data.orientation = newData.orientation;
    m_data.geometry = newData.geometry;
    m_data.availableGeometry = newData.availableGeometry;

    if (dpiChanged) {
        QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(screen(),
                                                                     newData.dpi.first,
                                                                     newData.dpi.second);
    }
    if (orientationChanged)
       QWindowSystemInterface::handleScreenOrientationChange(screen(), newData.orientation);
    if (geometryChanged) {
        QWindowSystemInterface::handleScreenGeometryChange(screen(),
                                                           newData.geometry, newData.availableGeometry);
    }
}
</code></pre>
<p dir="auto">It seems like the first screen is overwritten with the data from the second screen. The indexOfMonitor method returns an incorrect index due to the screen name not being unique. How can this problem be solved?</p>
]]></description><link>https://forum.qt.io/topic/139419/tooltips-and-menus-on-wrong-screen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 06:04:51 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139419.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 Sep 2022 11:14:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Tooltips and Menus on wrong screen on Wed, 28 Dec 2022 14:30:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rory_1">@<bdi>Rory_1</bdi></a> I have resolved this issue on MacOS.  I was restoring the geometry and state of  my application BUT in MacOS in the dock options I had the application desktop assigned to another desktop.</p>
]]></description><link>https://forum.qt.io/post/741722</link><guid isPermaLink="true">https://forum.qt.io/post/741722</guid><dc:creator><![CDATA[Rory_1]]></dc:creator><pubDate>Wed, 28 Dec 2022 14:30:59 GMT</pubDate></item><item><title><![CDATA[Reply to Tooltips and Menus on wrong screen on Tue, 27 Dec 2022 17:32:29 GMT]]></title><description><![CDATA[<p dir="auto">I have been seeing this issue on MacOS as well.  I cannot find a bug report for this.  Are there any suggestions for a workaround?</p>
]]></description><link>https://forum.qt.io/post/741606</link><guid isPermaLink="true">https://forum.qt.io/post/741606</guid><dc:creator><![CDATA[Rory_1]]></dc:creator><pubDate>Tue, 27 Dec 2022 17:32:29 GMT</pubDate></item><item><title><![CDATA[Reply to Tooltips and Menus on wrong screen on Fri, 18 Nov 2022 18:38:16 GMT]]></title><description><![CDATA[<p dir="auto">I have the same bug with Qt 6.2.4. Is it solved in newer versions?</p>
]]></description><link>https://forum.qt.io/post/736816</link><guid isPermaLink="true">https://forum.qt.io/post/736816</guid><dc:creator><![CDATA[larium]]></dc:creator><pubDate>Fri, 18 Nov 2022 18:38:16 GMT</pubDate></item></channel></rss>