<?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[QSortFilterProxyModel is very slow with strings]]></title><description><![CDATA[<p dir="auto">We have a problem with a simple QSortFilterProxyModel. My model is very slow when i use the sort method.<br />
Can anybody fix my problem?<br />
I put the code.</p>
<pre><code>@flightsModel = new LroOptimalDelayedFlightPlansModel();
sortModel = new QSortFilterProxyModel(this);
sortModel-&gt;setSourceModel(flightsModel);
ui-&gt;tableViewFlightPlans-&gt;setModel(sortModel);
configurationViewFlightPlans();
connect(flightsModel, SIGNAL(sortModel()), this, SLOT(sortModelAfterValuesChanged()));
</code></pre>
<p dir="auto">QVariant LroDelayedFlightPlansModel::data(const QModelIndex &amp;index, int role) const<br />
{<br />
if((!index.isValid()) ||<br />
(index.row() &gt;= rowCount(index)))<br />
{<br />
return QVariant();<br />
}</p>
<pre><code>if(role == Qt::DisplayRole)
{

    if(index.column() == 0)
    {
        return QString::fromStdString(fp.getFPs(index.row()).getCallsign());
    }
    else if(index.column() == 1)
    {
        return QString::fromStdString(fp.getFPs(index.row()).getOpType());
    }
    else if(index.column() == 2)
    {
        if(fp.getFPs(index.row()).getOpType() == "DEP")
        {
            return QString::fromStdString(
                        fp.getFPs(index.row()).getDepartureTimes().getItot());
        }
        else
        {
            return QString::fromStdString(
                        fp.getFPs(index.row() ).getArrivalTimes().getIldt());
        }
    }
    else if(index.column() == 3)
    {
        if(fp.getFPs(index.row()).getOpType() == "DEP")
        {
            return QString::fromStdString(
                        fp.getFPs(index.row()).getDepartureTimes().getStot());
        }
        else
        {
            return QString::fromStdString(
                        fp.getFPs(index.row()).getArrivalTimes().getSldt());
        }
    }
    else if(index.column() == 4)
    {
        if(fp.getFPs(index.row()).getOpType() == "DEP")
        {
            return QString::fromStdString(
                        fp.getFPs(index.row()).getDepartureTimes().getFtot());
        }
        else
        {
            return QString::fromStdString(
                        fp.getFPs(index.row()).getArrivalTimes().getFldt());
        }
    }
    else if(index.column() == 5)
    {
        return QVariant(fp.getFPs(index.row()).getForecastDelay());
    }
    else if(index.column() == 6)
    {
        return QVariant(fp.getFPs(index.row()).getPunctualityDelay());
    }
    else if(index.column() == 7)
    {
        return QString::fromStdString(fp.getFPs(index.row()).getRunwayAllocation());
    }

    return QVariant();
}
else if(role == Qt::TextAlignmentRole)
{
    return Qt::AlignCenter;
}
return QVariant();
</code></pre>
<p dir="auto">}<br />
@</p>
]]></description><link>https://forum.qt.io/topic/51006/qsortfilterproxymodel-is-very-slow-with-strings</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 05:30:28 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/51006.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 09 Feb 2015 16:13:40 GMT</pubDate><ttl>60</ttl></channel></rss>