PDA

View Full Version : Choice between Standard- and Abstract Item Model



hunsrus
10th March 2009, 15:03
hey folks,

i dont know which item model i have to chose / which one is the best for my issue. i've got a tree-view in which i would like to display some objects (which i create when loading files). but i want to have access through these objects: for example selecting one item should allow the user to "look into" the object, work with it and so on. also drag and drop should be possible. i hope you can imagine what i try to explain. up to the present i work with the QAbstractItemModel which causes many problems. Somebody has told me that the QModelIndexes are blame for that. can you help me? do you have an idea which one's "better" - or does somebody even have experience with both models?

regards & thanks in advance

sebastian

ComaWhite
10th March 2009, 18:35
From what I can possible understand from what you're talking about. You will need to return the Flags to allow the options in the flags() of the QAbstractItemModel; QAbstractItemModel's just provide the basic and you have to do pretty much all the implementation yourself. While the standard does it for you. But you would need to subclass it and override the drag functions for drag and drop. and edit the flags() also.

hunsrus
16th March 2009, 15:14
Thank you very much.

Do you know the difference between the QModelIndex and QPersistentModelIndex and do you have practice using it? It would be great if you could help me again...

edit: i just found out, that qpersistent model indexes are destroyed when refreshing the view. but refreshing the view is actually not necessary, is it? (if i insert an item the view is not resettet, right?)

Sebastian