PDA

View Full Version : About TreeModel and TreeItem?



yangyunzhao
14th August 2009, 02:10
I want to my programme works as:
http://www.qtcentre.org/forum/attachment.php?attachmentid=3563&stc=1&d=1250211726

My programme has one or more root nodes.
Each node has no or one or more nodes 、leaf.
Each node and leaf have own property ,such as name、icon、ID. Some property will display(such as name),some will not display(such as ID).

I inherit my TreeItem form QStandardItem and inherit my TreeModel from QStandardItemModel. Is it suitable?

I cannot completely understand QStandardItem.Could you give me more helps?Thanks a lot.

calmspeaker
14th August 2009, 06:48
I think you should try one of the two!
You could use model/view programming or directly use QTreeWidget.

franz
14th August 2009, 07:25
I think you should try one of the two!
You could use model/view programming or directly use QTreeWidget.

That's not really an answer to OP's question, is it? Or did OP edit the contents of the post?


I want to my programme works as:
[IMG]I inherit my TreeItem form QStandardItem and inherit my TreeModel from QStandardItemModel. Is it suitable?

Yeah it is.


I cannot completely understand QStandardItem.Could you give me more helps?
We can give more help, yes. However, it would be useful for all of us if you could specify what exactly you don't understand.

In general: QStandardItem helps you represent your tree structure in your code and knows how to access one specific piece of data. It will help you keep your actual model implementation simple, because you leave most of the work to the QStandardItem. It has a somewhat similar interface to models.