Actions
Support #967
closedSort Node in WStandardItemModel
Start date:
08/24/2011
Due date:
% Done:
0%
Estimated time:
Description
Hi,
How can i sort the nodes in a WStandardItemModel which contains custom data, using a particular field in my custom data ?
in particular this is my case:
typedef struct
{
std::string NodeStrId;
std::string NodeStrCategoria;
std::string NodeStrIdNameCreate;
bool IsEditable;
bool IsReadable;
bool IsWritable;
}T_REC_NODE_DATA_CPP;
.....
pNodeFile->setData(boost::any(NodeData), UserRole);
I want to be able to order using the field NodeStrId.
Thanks, Francesco.
Updated by Koen Deforche over 13 years ago
- Status changed from New to Resolved
- Assignee set to Koen Deforche
Hey Fransesco,
The easiest solution is to define a operator< in your struct, and use model->setSortRole(UserRole) to indicate that this data should be used for sorting.
Alternatively, you can reimplement WStandardItem::sortChildren() or WStandardItem::operator<
Regards,
koen
Updated by Koen Deforche about 13 years ago
- Status changed from Resolved to Closed
Actions