<?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[sqlite: QTreeView + QSqlTableModel]]></title><description><![CDATA[<p dir="auto">Hi!<br />
I have two tables in DB. There is 'one to multiple' connection.<br />
I need to:</p>
<ol>
<li>Show the main table.</li>
<li>Show the second table by row selection of the main table.</li>
<li>Needs to customization of the main table header: QLineEdit for each columns for filtering.</li>
</ol>
<pre><code>//Table1
    model1 = new QSqlTableModel(this);
    model1-&gt;setTable("table1_t");
    model1-&gt;setEditStrategy(QSqlTableModel::OnManualSubmit);
    model1-&gt;select();

    model1-&gt;setHeaderData(0, Qt::Horizontal, tr("Col1"));
    model1-&gt;setHeaderData(1, Qt::Horizontal, tr("Col2"));

    ui-&gt;view1-&gt;setModel(model1);

    //Table2
    model2 = new QSqlTableModel(this);
    model2-&gt;setTable("table2_t");
    model2-&gt;select();

    model2-&gt;setHeaderData(0, Qt::Horizontal, tr("Col1"));
    model2-&gt;setHeaderData(1, Qt::Horizontal, tr("Col2"));
    model2-&gt;setHeaderData(2, Qt::Horizontal, tr("Col3"));

    ui-&gt;view2-&gt;setModel(model2);
</code></pre>
<p dir="auto">How to connect view1 and view2 between each other?<br />
Thank you!</p>
]]></description><link>https://forum.qt.io/topic/115427/sqlite-qtreeview-qsqltablemodel</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 16:50:00 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/115427.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 01 Jun 2020 14:11:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to sqlite: QTreeView + QSqlTableModel on Mon, 01 Jun 2020 15:01:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sitesv">@<bdi>sitesv</bdi></a> said in <a href="/post/598327">sqlite: QTreeView + QSqlTableModel</a>:</p>
<blockquote>
<p dir="auto">How to connect view1 and view2 between each other?</p>
</blockquote>
<p dir="auto">See the <a href="https://doc.qt.io/qt-5/qabstractitemview.html#selectionChanged" target="_blank" rel="noopener noreferrer nofollow ugc">selectionChanged()</a> signal</p>
]]></description><link>https://forum.qt.io/post/598336</link><guid isPermaLink="true">https://forum.qt.io/post/598336</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Mon, 01 Jun 2020 15:01:22 GMT</pubDate></item></channel></rss>