In the example simpletreemodel of Qt4.3.1,how to justfy a node is leaf node or not?
view =new QTreeView();
class TreeModel : public QAbstractItemModel
{
}
class TreeItem
{
}
In the example simpletreemodel of Qt4.3.1,how to justfy a node is leaf node or not?
view =new QTreeView();
class TreeModel : public QAbstractItemModel
{
}
class TreeItem
{
}
If the node doesnt have any children, then it is a leaf, isnt it ??
Are you talking in terms of populating the tree, or evaluating from a tree if the node is leaf or not ?
When I double click the tree,I want to justfy the selected node is a leaf one or not.
In the class QModelIndex,I don't know how to get the child number of QModelIndex?
Qt Code:
To copy to clipboard, switch view to plain text mode
What are you using ? Model/View or QTreeWidget ?
If you are using model/view you can query QModelIndex::child(0,0)
If it returns a valid QModelIndex, you will know that this has some child. You can be sure because if it has child, firstt will be on row 0, col 0 .
Hope this helps
or you can use QAbstractItemModel::rowCount ( const QModelIndex & parent = QModelIndex() ) const which gives you number of rows for which parent is a parent :]
Qt Code:
index.model()->rowCount(index);To copy to clipboard, switch view to plain text mode
I would like to be a "Guru"
Useful hints (try them before asking):
- Use Qt Assistant
- Search the forum
If you haven't found solution yet then create new topic with smart question.
Bookmarks