I have a tree-like polymorphic data structure where the nodes are instances of the Node class (implemented by me) or any subclass of it. My application uses Boost heavily, and the nodes are actually represented by boost :: shared_ptr, not Node*.
Now I want to create a Qt model to wrap my tree data structure. Therefore, I need the ability to associate any model index with Node in my internal data structure. And here the problem arises:
Qt supports two ways to do this:
At first:
QModelIndex QAbstractItemModel::createIndex ( int row, int column, void * ptr = 0 ) const
Creates a model index for a given row and column with an internal ptr pointer.
And the second:
QModelIndex QAbstractItemModel::createIndex ( int row, int column, quint32 id ) const
Creates a model index for a given row and column with an internal identifier, identifier.
, Node ? shared_ptr ... , , shared_ptr CreateIndex(), - .
?
, , Boost/Qt , , .
10x .