Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QSortFilterProxyModel is very slow with strings

    General and Desktop
    1
    1
    965
    Loading More Posts
    • 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
      cimer84 last edited by

      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 Reply Quote 0
      • First post
        Last post