Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSortFilterProxyModel is very slow with strings
Qt 6.11 is out! See what's new in the release blog

QSortFilterProxyModel is very slow with strings

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cimer84
    wrote on last edited by
    #1

    We have a problem with a simple QSortFilterProxyModel. My model is very slow when i use the sort method.
    Can anybody fix my problem?
    I put the code.

    @flightsModel = new LroOptimalDelayedFlightPlansModel();
    sortModel = new QSortFilterProxyModel(this);
    sortModel->setSourceModel(flightsModel);
    ui->tableViewFlightPlans->setModel(sortModel);
    configurationViewFlightPlans();
    connect(flightsModel, SIGNAL(sortModel()), this, SLOT(sortModelAfterValuesChanged()));
    

    QVariant LroDelayedFlightPlansModel::data(const QModelIndex &index, int role) const
    {
    if((!index.isValid()) ||
    (index.row() >= rowCount(index)))
    {
    return QVariant();
    }

    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();
    

    }
    @

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved