<?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[Preventing cursor moving after text property is set]]></title><description><![CDATA[<p dir="auto">On several places the <a href="https://stackoverflow.com/questions/15801259/qlineedit-cursor-moves-to-end-after-textchanged-or-commitdata" target="_blank" rel="noopener noreferrer nofollow ugc">question</a> has been raised how to overcome the moving of a cursor to the end of the widget each time the text property is updated. This happens when a QLineEdit widget is connected via a QDataWidgetMapper to a model, and this model emits datachanged.</p>
<p dir="auto">The hints on multiple places is: store the cursor position. But I think this can only be achieved by a hack, which basically attaches the affected widgets under the model to the model. Before the data changed store the QTextCursor and after the signal, apply it again.</p>
<p dir="auto">The more practical question is: is there a way to do it in a less hacky way. Or prevent the moment from a programmatic input at all?</p>
]]></description><link>https://forum.qt.io/topic/150854/preventing-cursor-moving-after-text-property-is-set</link><generator>RSS for Node</generator><lastBuildDate>Fri, 06 Nov 2026 06:12:08 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/150854.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Oct 2023 12:24:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Preventing cursor moving after text property is set on Thu, 12 Oct 2023 19:38:33 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">Since you mention QDataWidgetMapper, you can use a custom property that will receive the data change and handle the cursor position the way you want it.</p>
]]></description><link>https://forum.qt.io/post/775881</link><guid isPermaLink="true">https://forum.qt.io/post/775881</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 12 Oct 2023 19:38:33 GMT</pubDate></item><item><title><![CDATA[Reply to Preventing cursor moving after text property is set on Fri, 13 Oct 2023 10:12:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> this in indeed a very cool trick that works even better than I thought.</p>
<p dir="auto">I have added a custom property <em>text2</em> that was set as the <em>user</em> property. This also means that I do not have to change the QDataWidgetMapper addMapping function, since that one requests the user property to begin with.</p>
<p dir="auto">Thank you very much for this sneaky/clever trick as <a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> points out :-)</p>
]]></description><link>https://forum.qt.io/post/775972</link><guid isPermaLink="true">https://forum.qt.io/post/775972</guid><dc:creator><![CDATA[skinkie]]></dc:creator><pubDate>Fri, 13 Oct 2023 10:12:43 GMT</pubDate></item><item><title><![CDATA[Reply to Preventing cursor moving after text property is set on Thu, 12 Oct 2023 20:47:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> said in <a href="/post/775881">Preventing cursor moving after text property is set</a>:</p>
<blockquote>
<p dir="auto">you can use a custom property that will receive the data change and handle the cursor position the way you want it.</p>
</blockquote>
<p dir="auto">That's sneaky/clever!</p>
]]></description><link>https://forum.qt.io/post/775895</link><guid isPermaLink="true">https://forum.qt.io/post/775895</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 12 Oct 2023 20:47:43 GMT</pubDate></item><item><title><![CDATA[Reply to Preventing cursor moving after text property is set on Thu, 12 Oct 2023 19:38:33 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">Since you mention QDataWidgetMapper, you can use a custom property that will receive the data change and handle the cursor position the way you want it.</p>
]]></description><link>https://forum.qt.io/post/775881</link><guid isPermaLink="true">https://forum.qt.io/post/775881</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 12 Oct 2023 19:38:33 GMT</pubDate></item></channel></rss>