<?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[QCursor::setPos doesn&#x27;t support float arguments?]]></title><description><![CDATA[<p dir="auto">Hello!<br />
Noticed that <code>QCursor::setPos</code> only accept <code>int</code> coordinates, so I can't perfectly set the mouse pos under high DPI screens?</p>
<p dir="auto">I'm trying to make a drag zone on QML that prevents the mouse to go outside the window while dragging:</p>
<ul>
<li>start dragging, record start coordinate</li>
<li>onPositionChanged, calculate mouse coord delta, emit event</li>
<li><code>QCursor:::setPos</code> move mouse back to start coord</li>
<li>onPositionChanged...</li>
<li>In the end the user is able to move something (like a slider, based on emitted delta events)<br />
while preventing the mouse to go outside the window</li>
</ul>
<p dir="auto">On 100% scaled screens it works fine, but on 125% scaled screen the moved "thing" starts drifting, e.g. if you move the mouse in a circle the "thing" starts to drift to the corner of the window.</p>
<p dir="auto">My guess is QCursor::setPos accepts <code>int</code> arguments so each time it's not perfectly set to the start coordinate, causing a bias to the delta events.</p>
<p dir="auto">Platform is Windows.</p>
<p dir="auto">Thanks!</p>
]]></description><link>https://forum.qt.io/topic/164255/qcursor-setpos-doesn-t-support-float-arguments</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 20:58:21 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164255.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 13 Feb 2026 06:51:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QCursor::setPos doesn&#x27;t support float arguments? on Fri, 13 Feb 2026 12:10:00 GMT]]></title><description><![CDATA[<p dir="auto">There might be a rounding error somewhere but you can't position on a half pixel in e.g. windows - see <a href="https://learn.microsoft.com/de-de/windows/win32/api/winuser/nf-winuser-setcursorpos" target="_blank" rel="noopener noreferrer nofollow ugc">SetCursorPos</a>.<br />
So yes, with 125% the logical position 61/62 is mapped to the physical position 76/78 while it should be 76,25/77,5 but SetCursorPos can't handle this.</p>
]]></description><link>https://forum.qt.io/post/836221</link><guid isPermaLink="true">https://forum.qt.io/post/836221</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Fri, 13 Feb 2026 12:10:00 GMT</pubDate></item><item><title><![CDATA[Reply to QCursor::setPos doesn&#x27;t support float arguments? on Fri, 13 Feb 2026 07:00:25 GMT]]></title><description><![CDATA[<p dir="auto">Example codes:</p>
<ul>
<li>QML drag zone: <a href="https://pastebin.com/WjEGTBiV" target="_blank" rel="noopener noreferrer nofollow ugc">https://pastebin.com/WjEGTBiV</a></li>
<li>QML main: <a href="https://pastebin.com/0eZJqFVh" target="_blank" rel="noopener noreferrer nofollow ugc">https://pastebin.com/0eZJqFVh</a></li>
<li>C++ helper: <a href="https://pastebin.com/1L66xgTh" target="_blank" rel="noopener noreferrer nofollow ugc">https://pastebin.com/1L66xgTh</a></li>
</ul>
]]></description><link>https://forum.qt.io/post/836212</link><guid isPermaLink="true">https://forum.qt.io/post/836212</guid><dc:creator><![CDATA[FishBoneEK]]></dc:creator><pubDate>Fri, 13 Feb 2026 07:00:25 GMT</pubDate></item></channel></rss>