<?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[Display SQLite DB content on ListWidget]]></title><description><![CDATA[<p dir="auto">How can I display the content of my SQLiteDB on a ListWidget?<br />
I tried several ways, but when I want to add it as a new item, I get the message, that QString (or QSqlQuery) can't be converted to QListWidgetItem.</p>
]]></description><link>https://forum.qt.io/topic/83242/display-sqlite-db-content-on-listwidget</link><generator>RSS for Node</generator><lastBuildDate>Wed, 11 Mar 2026 00:43:14 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/83242.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 Sep 2017 10:55:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Display SQLite DB content on ListWidget on Thu, 14 Sep 2017 13:07:09 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
you can use<br />
<a href="http://doc.qt.io/qt-5/qsqlquery.html#lastError" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qsqlquery.html#lastError</a><br />
to see if something wrong and its<br />
also recommended<br />
to use the debugger to step into the function<br />
and see what gets executed.</p>
]]></description><link>https://forum.qt.io/post/415316</link><guid isPermaLink="true">https://forum.qt.io/post/415316</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 14 Sep 2017 13:07:09 GMT</pubDate></item><item><title><![CDATA[Reply to Display SQLite DB content on ListWidget on Thu, 14 Sep 2017 12:57:22 GMT]]></title><description><![CDATA[<p dir="auto">Hi! Thanks for the answers!<br />
Actually I also wanted to make the items checkable, that's why I started with a ListWidget.<br />
However, I don't get any error messages for now, but the program is not doing anything when I execute and click on the ListWidget.<br />
Check out the code:</p>
<pre><code>/void Hochladen::on_listWidget_theme_clicked(const QModelIndex &amp;index)
{

    NeuesThema conn; //Zur Verbindung mit der Themen Datenbank

    QSqlQuery query;
    conn.connOpen(); //Öffnen der Verbindung

     query.prepare("select * from themen");
    if (query.exec()) {

        if(query.next()) {

    QString a = query.boundValue(0).toString();

    //reduced the code for now:
    //ui-&gt;listWidget_theme-&gt;addItem( QString );
    //QListWidgetItem *item = new QListWidgetItem();
    //item-&gt;setCheckState(Qt::Unchecked);
    
     ui-&gt;listWidget_theme-&gt;addItem( a );

     conn.connClose();
        }
    }
}```</code></pre>
]]></description><link>https://forum.qt.io/post/415314</link><guid isPermaLink="true">https://forum.qt.io/post/415314</guid><dc:creator><![CDATA[Johanna0701]]></dc:creator><pubDate>Thu, 14 Sep 2017 12:57:22 GMT</pubDate></item><item><title><![CDATA[Reply to Display SQLite DB content on ListWidget on Thu, 14 Sep 2017 04:02:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johanna0701">@<bdi>Johanna0701</bdi></a></p>
<p dir="auto">Hi,</p>
<p dir="auto">As <a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a>  said use QListView for dispaly the contents.</p>
<p dir="auto">For this you have to do like this,<br />
QSqlQuery query;<br />
query.prepare("Your query");<br />
QSqlQueryModel model;<br />
model.setQuery(query);<br />
QListView view;<br />
view.setModel(model);</p>
]]></description><link>https://forum.qt.io/post/415233</link><guid isPermaLink="true">https://forum.qt.io/post/415233</guid><dc:creator><![CDATA[Venkatesh V]]></dc:creator><pubDate>Thu, 14 Sep 2017 04:02:53 GMT</pubDate></item><item><title><![CDATA[Reply to Display SQLite DB content on ListWidget on Wed, 13 Sep 2017 11:10:50 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
you call<br />
ui-&gt;listWidget-&gt;addItem( QString  );</p>
<p dir="auto">when you loop over the QSqlQuery results</p>
<p dir="auto">However, why such involving way ?</p>
<p dir="auto">If you use a list view and this model, its almost for free.<br />
<a href="http://doc.qt.io/qt-5/qsqlquerymodel.html#details" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qsqlquerymodel.html#details</a></p>
]]></description><link>https://forum.qt.io/post/415116</link><guid isPermaLink="true">https://forum.qt.io/post/415116</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Wed, 13 Sep 2017 11:10:50 GMT</pubDate></item></channel></rss>