C++ (Qt)const int NUM_FIRST = 3;bool MySortFilterProxyModel::lessThan ( const QModelIndex & left, const QModelIndex & right ) const { int lRow = qMin(left.row(), NUM_FIRST); int rRow = qMin(right.row(), NUM_FIRST); if (lRow < rRow) return true; if (lRow > rRow) return false; return QSortFilterProxyModel::lessThan(left, right); }
C++ (Qt)bool MySortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const{ int lRow = qMin(left.row(), 3); int rRow = qMin(right.row(), 3); if (sortOrder() == Qt::DescendingOrder) { lRow = -lRow; rRow = -rRow; } if (lRow < rRow) return true; if (lRow > rRow) return false; return QSortFilterProxyModel::lessThan(left, right);}}