<?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[How to add columns in QTableView?]]></title><description><![CDATA[<p dir="auto">Is it possible to add columns to a QTableView using qtDesiger?<br />
In QTableWidget just right-click  to add columns and rows, is there something similar for QTableView?<br />
I didn't find many tutorials with QTableView on the internet and in <a href="https://doc.qt.io/qt-5/qtableview.html#columnAt" target="_blank" rel="noopener noreferrer nofollow ugc">documentation</a>.</p>
<p dir="auto">I want to take data from an existing database and place it in this QTableView without the user being able to edit or change the table properties.</p>
]]></description><link>https://forum.qt.io/topic/122294/how-to-add-columns-in-qtableview</link><generator>RSS for Node</generator><lastBuildDate>Sun, 07 Jun 2026 22:56:44 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/122294.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 03 Jan 2021 04:52:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to add columns in QTableView? on Mon, 04 Jan 2021 08:02:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/_jao_victor_">@<bdi>_jao_victor_</bdi></a> said in <a href="/post/635611">How to add columns in QTableView?</a>:</p>
<blockquote>
<p dir="auto">When you say model, do you mean a database table?</p>
</blockquote>
<p dir="auto">A model does not <em>have to be</em> a database, but it <em>can</em> be.  A database is an example of a model.  You cannot use a database or other model at <em>design-time</em> to populate a view's columns or rows in Qt <strong>Designer</strong>.  You'd have to use a <code>QTableWidget</code> at design-time.  And that means typing values/column headings into cells, not fetching them from a database.</p>
<p dir="auto">Using a <code>QTableView</code> attached to a model such as a database at <em>runtime</em> is no problem.</p>
]]></description><link>https://forum.qt.io/post/635652</link><guid isPermaLink="true">https://forum.qt.io/post/635652</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Mon, 04 Jan 2021 08:02:22 GMT</pubDate></item><item><title><![CDATA[Reply to How to add columns in QTableView? on Wed, 06 Jan 2021 04:20:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> Is it possible to take the data from the table and store it in some Python structure, for example, a list and then put it in a QTableView?</p>
]]></description><link>https://forum.qt.io/post/636088</link><guid isPermaLink="true">https://forum.qt.io/post/636088</guid><dc:creator><![CDATA[_jao_victor_]]></dc:creator><pubDate>Wed, 06 Jan 2021 04:20:14 GMT</pubDate></item><item><title><![CDATA[Reply to How to add columns in QTableView? on Mon, 04 Jan 2021 08:02:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/_jao_victor_">@<bdi>_jao_victor_</bdi></a> said in <a href="/post/635611">How to add columns in QTableView?</a>:</p>
<blockquote>
<p dir="auto">When you say model, do you mean a database table?</p>
</blockquote>
<p dir="auto">A model does not <em>have to be</em> a database, but it <em>can</em> be.  A database is an example of a model.  You cannot use a database or other model at <em>design-time</em> to populate a view's columns or rows in Qt <strong>Designer</strong>.  You'd have to use a <code>QTableWidget</code> at design-time.  And that means typing values/column headings into cells, not fetching them from a database.</p>
<p dir="auto">Using a <code>QTableView</code> attached to a model such as a database at <em>runtime</em> is no problem.</p>
]]></description><link>https://forum.qt.io/post/635652</link><guid isPermaLink="true">https://forum.qt.io/post/635652</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Mon, 04 Jan 2021 08:02:22 GMT</pubDate></item><item><title><![CDATA[Reply to How to add columns in QTableView? on Sun, 03 Jan 2021 19:30:02 GMT]]></title><description><![CDATA[<p dir="auto">No, a model is not limited to a database.</p>
<p dir="auto">See <a href="https://doc.qt.io/qt-5/model-view-programming.html" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
]]></description><link>https://forum.qt.io/post/635615</link><guid isPermaLink="true">https://forum.qt.io/post/635615</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 03 Jan 2021 19:30:02 GMT</pubDate></item><item><title><![CDATA[Reply to How to add columns in QTableView? on Sun, 03 Jan 2021 18:38:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> When you say model, do you mean a database table?</p>
]]></description><link>https://forum.qt.io/post/635611</link><guid isPermaLink="true">https://forum.qt.io/post/635611</guid><dc:creator><![CDATA[_jao_victor_]]></dc:creator><pubDate>Sun, 03 Jan 2021 18:38:29 GMT</pubDate></item><item><title><![CDATA[Reply to How to add columns in QTableView? on Sun, 03 Jan 2021 15:47:20 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">You cannot do that with Designer. QTableView requires a model so you'll have to do some coding to set it.</p>
]]></description><link>https://forum.qt.io/post/635588</link><guid isPermaLink="true">https://forum.qt.io/post/635588</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 03 Jan 2021 15:47:20 GMT</pubDate></item><item><title><![CDATA[Reply to How to add columns in QTableView? on Sun, 03 Jan 2021 07:58:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/_jao_victor_">@<bdi>_jao_victor_</bdi></a><br />
My experience is that there is little you can do with a <code>QTableView</code> in the Designer.  You have to use the <code>QTableWidget</code> there if you want to do design-time things.</p>
<p dir="auto">But <code>QTableWidget</code> is not the same as <code>QTableView</code>.  It is a wrapper around it, notably with its own, internal model structure.  If you want to connect a table view to an existing database source <code>QTableWidget</code> is not an optimal choice.</p>
<p dir="auto">Since you want "without the user being able to edit or change the table properties", just connect the <code>QTableView</code> to the database model at runtime and it will have the same columns.  Yes, you do not get to see it laid out at design-time.</p>
]]></description><link>https://forum.qt.io/post/635525</link><guid isPermaLink="true">https://forum.qt.io/post/635525</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Sun, 03 Jan 2021 07:58:07 GMT</pubDate></item></channel></rss>