<?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[Spanish&#x2F;french characters not displayed properly in QTableWidget]]></title><description><![CDATA[<p dir="auto">Hello<br />
I have an application in which i am required to read a CSV file (Comma Separated values) and display the values in a QTableWidget. This works perfect with all English characters. However, for internationalisation, I am required to also display characters in different European languages like Spanish and French. So if the CSV File contains a non english character, it is not displayed properly in the QTableWidget. The characters are just seen as some symbols.<br />
How can this be done?<br />
Regards</p>
<p dir="auto">KK</p>
]]></description><link>https://forum.qt.io/topic/65424/spanish-french-characters-not-displayed-properly-in-qtablewidget</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 16:19:34 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/65424.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 Mar 2016 13:08:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Spanish&#x2F;french characters not displayed properly in QTableWidget on Tue, 29 Mar 2016 05:56:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thecrowkaka">@<bdi>TheCrowKaka</bdi></a> said:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johansolo">@<bdi>JohanSolo</bdi></a><br />
Thanks for your time to answer my question.<br />
I am unable to control the encoding of the CSV File. The CSV file can be created from any of the spreadsheet applications.</p>
</blockquote>
<p dir="auto">If you're on Windows it's most likely any other encoding but UTF-8 which will be used by default. Better check (and set if needed) manually the encoding before trying to import the data in your program.</p>
]]></description><link>https://forum.qt.io/post/319832</link><guid isPermaLink="true">https://forum.qt.io/post/319832</guid><dc:creator><![CDATA[JohanSolo]]></dc:creator><pubDate>Tue, 29 Mar 2016 05:56:23 GMT</pubDate></item><item><title><![CDATA[Reply to Spanish&#x2F;french characters not displayed properly in QTableWidget on Tue, 29 Mar 2016 03:41:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johansolo">@<bdi>JohanSolo</bdi></a><br />
Thanks for your time to answer my question.<br />
I am unable to control the encoding of the CSV File. The CSV file can be created from any of the spreadsheet applications.<br />
Regarding the codec of my application, I am setting the codec in the main.c as follows:</p>
<pre><code>QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
</code></pre>
<p dir="auto">I have also tried setting the codec to the text stream. My source code for reading the csv file and listing in a QTableWidget is as follows:</p>
<pre><code>void csvfileDialog::on_btn_listfile_clicked()
{
    QString data;
    QFile importedCSV(ui-&gt;txt_csvfilename-&gt;text());
    QStringList rowOfData;
    QStringList rowData;
    if(ui-&gt;txt_delimiter-&gt;text().trimmed().isEmpty())
        ui-&gt;txt_delimiter-&gt;setText(",");

    data.clear();
    rowOfData.clear();
    rowData.clear();
    if (importedCSV.open(QFile::ReadOnly))
    {
        QTextStream csvstream(&amp;importedCSV);
        csvstream.setCodec("UTF-8");
        data = csvstream.readAll();
//        data = importedCSV.readAll();
        rowOfData = data.split("\n");
        importedCSV.close();
    }
    else
        return;
    rowData = rowOfData.at(0).split(ui-&gt;txt_delimiter-&gt;text().trimmed());
    ui-&gt;tab_csvlist-&gt;setColumnCount(rowData.count());
    ui-&gt;tab_csvlist-&gt;setRowCount(rowOfData.count()-1);
    for (int x = 0; x &lt; rowOfData.size(); x++)
    {
        rowData = rowOfData.at(x).split(ui-&gt;txt_delimiter-&gt;text().trimmed());
        for (int y = 0; y &lt; rowData.size(); y++)
        {
            QString tempstr = rowData.at(y);
            qDebug()&lt;&lt;tempstr.toUtf8();
            ui-&gt;tab_csvlist-&gt;setItem(x,y,new QTableWidgetItem(tempstr));
        }
    }
}
</code></pre>
<p dir="auto">Unable to understand where am I wrong.</p>
]]></description><link>https://forum.qt.io/post/319824</link><guid isPermaLink="true">https://forum.qt.io/post/319824</guid><dc:creator><![CDATA[TheCrowKaka]]></dc:creator><pubDate>Tue, 29 Mar 2016 03:41:03 GMT</pubDate></item><item><title><![CDATA[Reply to Spanish&#x2F;french characters not displayed properly in QTableWidget on Thu, 24 Mar 2016 14:05:09 GMT]]></title><description><![CDATA[<p dir="auto">What is the encoding of your CSV file? Did you set the loading codec accordingly when getting the data from the CSV?</p>
]]></description><link>https://forum.qt.io/post/319297</link><guid isPermaLink="true">https://forum.qt.io/post/319297</guid><dc:creator><![CDATA[JohanSolo]]></dc:creator><pubDate>Thu, 24 Mar 2016 14:05:09 GMT</pubDate></item></channel></rss>