i have simple model view treeview with QSortFilterProxyModel proxy to sort the columns and QStandardItemModel as the model
in each columns there are string that gets sor
That's because by default, QSortFilterProxyModel sorts by DisplayRole. If that returns a string, it will sort the string. To have the model sort by some other value, define a custom sort role in the source model and set it on the proxy:
class MyModel {
...
enum Role {
SortRole=Qt::UserRole
};
QVariant data( ... ) const {
...
switch ( role ) {
case Qt::DisplayRole:
return value as string;
case SortRole:
return value as int;
}
}
};
...
sortfilterproxy->setSortRole( MyModel::SortRole );
Your second question: What is m_model? The source model, or the sortfilterproxymodel? The former is never changed by sorting, the sorting happens only in the proxy.