PDA

View Full Version : Exploring the items of a QtreeWidget using its model



tonnot
25th July 2011, 14:01
I have a QtreeWidget, and I want to 'explore' it using it model data.
I have a vector<QStandardItemModel*>. First I add the main model for the tree.
I explore it and add new models to my vector if I find nodes with children.
( I think that with a simple code I can transverse the whole tree).

Ok, now I have :

tree_model= (QStandardItemModel*)QTreeWidget->model();
tree_model->rowCount();
tree_model->columnCount();


But I dont know how to get the 'node' data. (text and datamodel)
I have to use a modelIndex?

QModelIndex mi = tree_model>index(row, col); ???
But I could to use:

tree_model->item(row,col)->text();
tree_model->item(row,col)->has_children;
tree_model->item(row,col)->model()


But I have errors .... And I don find nothing useful at help reference
Any help ? Thanks.

high_flyer
26th July 2011, 11:29
I have a vector<QStandardItemModel*>.
Why?
Why use a vector of models?
How do you use multiple models on one tree?

tonnot
26th July 2011, 19:09
The help reference for model-view is very poor.
Finally I have found some useful at :
http://developer.qt.nokia.com/wiki/Model_Test
I think that is time for improve the QT reference help.
Thanks

high_flyer
27th July 2011, 09:01
I disagree.
Qt documentation is one of the best I know, and often people will explicitly point out how good the documentation is when they just come across Qt for the first time, specially when compared to other toolkits.
I agree, that since 4.7, the quality of the documentation has suffered, I guess due to the large amount of added classes, and various other issues we all know that are going on at Nokia, never the less, I find the documentation still to be one of the best out there. (That doesn't mean it can't be improved!)
Are you sure you read ALL there is in the documentation about Model/Viewer?
http://doc.qt.nokia.com/latest/model-view-programming.html#view-classes
http://doc.qt.nokia.com/latest/modelview.html
And this will be very much you case I think:
http://doc.qt.nokia.com/latest/itemviews-simpletreemodel.html

And these links are not all.
As you can see, Model Viewe is VERY well documented, and I doubt you took the trouble to read all of that.
And if I am wrong, and you did, I just can't follow on your conclusion...

wysota
27th July 2011, 09:20
If you have specific questions about ItemViews, then ask. Just be clear and explicit about what you want. Especially don't use ambiguous terms like "explore". I have no idea what "exploring a QTreeWidget" means. I would guess it was reading its documentation and playing around with its features but that's probably not what you meant.

tonnot
28th July 2011, 13:42
When I refer to the concept of improve the help I wanted to say the "QT Reference documentation" you can use inside QtCreator.
It's time to make an upgrade of it with the information you can find on web,
http://doc.qt.nokia.com/latest ...
http://developer.qt.nokia.com/wiki/Model_Test
... etc.
I think that it'd be neccesary to include this usefull information inside QT reference doc. The copyright note of it says 'nokia 2008 -2010'. (January or December?) .

DIGIA has to do this work?

I like QT but there is a few things related with the way you can learn QT & QTcreator that would have to be better.
Thanks