get an index from an item (for a QtreeView)



  • I have a QtreeView, and a model from a QAbstractItemModel and a class named "Location" who is my item linked with my model.
    And then, in my model, i try to construct a method named "indexOf(Location *location)" (who is exactly the same function of a QStandardItem named "indexFromItem(QStandardItem *item)" )...
    At this time, i'm locked at just:
    QModelIndex Location_Model::indexOf(Location *location) {
    return createindex(0,0,location);
    }

    the problem is that my row is 0... and then this never give me back the correct index... what i can do for know the row before have the index ?
    could you help me to create this indexOf ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.