<?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[Updating widget with QSqlTableModel]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I have a database that look like this : <img src="https://ddgobkiprc33d.cloudfront.net/6a5a49df-9b80-4271-8576-c07c77bfd90c.png" alt="db.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">And my goal is to make a custom widget out of each row of the database<br />
<img src="https://ddgobkiprc33d.cloudfront.net/74d43210-2c22-4f55-bba9-b3133821b558.png" alt="draw.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">For that I decided to use a QSqlTableModel and for each custom widget that I make, create a QWidgetMapper in whose purpose is to map a specific row to the QLabels of my custom widget like so</p>
<pre><code>
 m_dataMapper-&gt;addMapping(m_descriptionLabel, model-&gt;fieldIndex("description"), "text");
m_dataMapper-&gt;addMapping(m_tagLabel, model-&gt;fieldIndex("tag"), "text");
m_dataMapper-&gt;setCurrentIndex(row);
</code></pre>
<p dir="auto">In my application, I allow the user to modify those label using QDialog, but one thing I am not able to do is update the database using my model and force it to update automatically the QLabels of my custom widget. Should I use a delegate ? What am I doing wrong</p>
]]></description><link>https://forum.qt.io/topic/127150/updating-widget-with-qsqltablemodel</link><generator>RSS for Node</generator><lastBuildDate>Fri, 09 Oct 2026 21:45:04 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/127150.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 31 May 2021 05:50:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Updating widget with QSqlTableModel on Tue, 01 Jun 2021 09:51:55 GMT]]></title><description><![CDATA[<p dir="auto">A delegate is not a widget. It paints itself using a <code>paint()</code> method that gets data directly from the model</p>
]]></description><link>https://forum.qt.io/post/662788</link><guid isPermaLink="true">https://forum.qt.io/post/662788</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Tue, 01 Jun 2021 09:51:55 GMT</pubDate></item><item><title><![CDATA[Reply to Updating widget with QSqlTableModel on Mon, 31 May 2021 18:05:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vronin">@<bdi>VRonin</bdi></a><br />
But the delegate will now update the widgets unless and told force him to call setText() on the QLabels even though those qlabels are mapped to the model, am I correct ?</p>
]]></description><link>https://forum.qt.io/post/662664</link><guid isPermaLink="true">https://forum.qt.io/post/662664</guid><dc:creator><![CDATA[Harsaith]]></dc:creator><pubDate>Mon, 31 May 2021 18:05:34 GMT</pubDate></item><item><title><![CDATA[Reply to Updating widget with QSqlTableModel on Mon, 31 May 2021 10:10:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/harsaith">@<bdi>Harsaith</bdi></a> said in <a href="/post/662503">Updating widget with QSqlTableModel</a>:</p>
<blockquote>
<p dir="auto">Should I use a delegate ?</p>
</blockquote>
<p dir="auto"><img src="https://gifsb.in/misc-reactions/a-1000-times-yes.gif" alt="1000 times yes" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/662574</link><guid isPermaLink="true">https://forum.qt.io/post/662574</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Mon, 31 May 2021 10:10:53 GMT</pubDate></item></channel></rss>