Project

General

Profile

Actions

Support #967

closed

Sort Node in WStandardItemModel

Added by Francesco Alfano about 13 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
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.

Actions #1

Updated by Koen Deforche about 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

Actions #2

Updated by Koen Deforche about 13 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF