<?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[Moving the Qt App]]></title><description><![CDATA[<p dir="auto">in the mainwindow class in header i have</p>
<pre><code class="language-c++">protected:
    void mousePressEvent(QMouseEvent *) override;
</code></pre>
<p dir="auto">and then in the mainwindow cpp i have</p>
<pre><code class="language-c++">void MainWindow::mousePressEvent(QMouseEvent * event)
{
    if(isMaximized() == false &amp;&amp; event-&gt;type() == QEvent::MouseButtonPress &amp;&amp; event-&gt;buttons() == Qt::LeftButton)
    {
        if (QWindow *window = windowHandle())
            window-&gt;startSystemMove();
    }

    _MousePos_x = event-&gt;x();
    _MousePos_y = event-&gt;y();
}
</code></pre>
<p dir="auto">this works great and all but no matter where i click i can move the window! what i realy want is to check and only enable movement of  window if (ui-&gt;frameTopBar) is clicked on but how?</p>
]]></description><link>https://forum.qt.io/topic/126357/moving-the-qt-app</link><generator>RSS for Node</generator><lastBuildDate>Sat, 26 Sep 2026 18:52:18 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/126357.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 May 2021 13:03:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Moving the Qt App on Wed, 05 May 2021 16:16:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kshegunov">@<bdi>kshegunov</bdi></a> said in <a href="/post/658098">Moving the Qt App</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vronin">@<bdi>VRonin</bdi></a> said in <a href="/post/658092">Moving the Qt App</a>:</p>
<blockquote>
<p dir="auto">The event filter is 100% the correct solution but the quick and dirty one could be:</p>
</blockquote>
<p dir="auto">Maybe. Promoting to a custom widget is a possibility.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kris-revi">@<bdi>Kris-Revi</bdi></a> said in <a href="/post/658086">Moving the Qt App</a>:</p>
<blockquote>
<p dir="auto">but how would i implement the QMouseEvent into the eventFilter thing?</p>
</blockquote>
<p dir="auto">Exactly like in the code you showed: you check the source, then check the event type and react to it however you like. An event filter just intercepts the events before they reach the original destination. Look up <code>QMouseEvent</code>, <code>QEvent</code> and especially its <code>type</code> property and <code>eventFilter()</code> together with <code>installEventFilter</code>, the latter you'd typically do after the call to <code>setupUi</code>.</p>
</blockquote>
<p dir="auto">thanks for that! im a bit slow! but your explanation helped me actually! :) got it working fine now!</p>
]]></description><link>https://forum.qt.io/post/658116</link><guid isPermaLink="true">https://forum.qt.io/post/658116</guid><dc:creator><![CDATA[Kris Revi]]></dc:creator><pubDate>Wed, 05 May 2021 16:16:38 GMT</pubDate></item><item><title><![CDATA[Reply to Moving the Qt App on Wed, 05 May 2021 15:16:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vronin">@<bdi>VRonin</bdi></a> said in <a href="/post/658092">Moving the Qt App</a>:</p>
<blockquote>
<p dir="auto">The event filter is 100% the correct solution but the quick and dirty one could be:</p>
</blockquote>
<p dir="auto">Maybe. Promoting to a custom widget is a possibility.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kris-revi">@<bdi>Kris-Revi</bdi></a> said in <a href="/post/658086">Moving the Qt App</a>:</p>
<blockquote>
<p dir="auto">but how would i implement the QMouseEvent into the eventFilter thing?</p>
</blockquote>
<p dir="auto">Exactly like in the code you showed: you check the source, then check the event type and react to it however you like. An event filter just intercepts the events before they reach the original destination. Look up <code>QMouseEvent</code>, <code>QEvent</code> and especially its <code>type</code> property and <code>eventFilter()</code> together with <code>installEventFilter</code>, the latter you'd typically do after the call to <code>setupUi</code>.</p>
]]></description><link>https://forum.qt.io/post/658098</link><guid isPermaLink="true">https://forum.qt.io/post/658098</guid><dc:creator><![CDATA[kshegunov]]></dc:creator><pubDate>Wed, 05 May 2021 15:16:27 GMT</pubDate></item><item><title><![CDATA[Reply to Moving the Qt App on Wed, 05 May 2021 14:46:58 GMT]]></title><description><![CDATA[<p dir="auto">The event filter is 100% the correct solution but the quick and dirty one could be:</p>
<p dir="auto"><code>if(QRect(mapToGlobal(ui-&gt;frameTopBar-&gt;pos()),ui-&gt;frameTopBar-&gt;size()).contains(event-&gt;globalPos()))</code></p>
]]></description><link>https://forum.qt.io/post/658092</link><guid isPermaLink="true">https://forum.qt.io/post/658092</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Wed, 05 May 2021 14:46:58 GMT</pubDate></item><item><title><![CDATA[Reply to Moving the Qt App on Wed, 05 May 2021 14:12:21 GMT]]></title><description><![CDATA[<p dir="auto">im not 100% sure about this eventFilter stuff but i got this working for another thing</p>
<h3>Header</h3>
<pre><code class="language-c++">bool eventFilter(QObject *object, QEvent *event) override;
</code></pre>
<h3>Cpp</h3>
<pre><code class="language-c++">bool MainWindow::eventFilter(QObject *object, QEvent *event)
{
    if (object == (QObject*) ui-&gt;frameLedStripDeviceContainer)
    {
        if (event-&gt;type() == QEvent::Enter)
        {
            if ( devicemenucollapsed )
            {
                ui-&gt;frameDeviceMenu-&gt;setMinimumWidth(264);
                ui-&gt;frameDeviceMenu-&gt;setMaximumWidth(264);
                ui-&gt;labelLedStripDevices-&gt;setVisible(true);
                ui-&gt;labelLedStripDevicesSeparator-&gt;setVisible(false);
                ui-&gt;labelLedMatrixDevices-&gt;setVisible(true);
                ui-&gt;labelLedMatrixDevicesSeparator-&gt;setVisible(false);
                ui-&gt;labelSoftwareVersion-&gt;setVisible(true);

                for (QPushButton * dButtons : _DeviceButtonList)
                {
                    dButtons-&gt;setText( dButtons-&gt;property("orgtext").toString() );
                }
            }
        }
        else if (event-&gt;type() == QEvent::Leave)
        {
            if ( devicemenucollapsed )
            {
                ui-&gt;frameDeviceMenu-&gt;setMinimumWidth(52);
                ui-&gt;frameDeviceMenu-&gt;setMaximumWidth(52);
                ui-&gt;labelLedStripDevices-&gt;setVisible(false);
                ui-&gt;labelLedStripDevicesSeparator-&gt;setVisible(true);
                ui-&gt;labelLedMatrixDevices-&gt;setVisible(false);
                ui-&gt;labelLedMatrixDevicesSeparator-&gt;setVisible(true);
                ui-&gt;labelSoftwareVersion-&gt;setVisible(false);

                for (QPushButton * dButtons : _DeviceButtonList)
                {
                    dButtons-&gt;setText("");
                }
            }
        }
        return QWidget::eventFilter(object, event);
    }
}

ui-&gt;frameLedStripDeviceContainer-&gt;installEventFilter(this);
</code></pre>
<p dir="auto">but how would i implement the QMouseEvent into the eventFilter thing?</p>
]]></description><link>https://forum.qt.io/post/658086</link><guid isPermaLink="true">https://forum.qt.io/post/658086</guid><dc:creator><![CDATA[Kris Revi]]></dc:creator><pubDate>Wed, 05 May 2021 14:12:21 GMT</pubDate></item><item><title><![CDATA[Reply to Moving the Qt App on Wed, 05 May 2021 13:40:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kris-revi">@<bdi>Kris-Revi</bdi></a><br />
install an <a href="https://doc.qt.io/qt-5/eventsandfilters.html#event-filters" target="_blank" rel="noopener noreferrer nofollow ugc">event filter</a> on <code>ui-&gt;frameTopBar</code></p>
]]></description><link>https://forum.qt.io/post/658082</link><guid isPermaLink="true">https://forum.qt.io/post/658082</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Wed, 05 May 2021 13:40:28 GMT</pubDate></item></channel></rss>