PDA

View Full Version : QAbstractTableModel for QTreeView?



Michiel
14th May 2007, 21:40
I have a QTreeView that really only shows a 2-dimensional dataset. I just think a treeview (really just a list with columns) is more appropriate for this data than a table.

Still, the Qt documentation tells me that the QAbstractTableModel is not suitable for use with treeviews. Do they only mean hierarchical treeviews? Or is there an incompatibility even for 2D treeviews?

I'd just like to know that before I start coding.

Thanks!

wysota
14th May 2007, 22:21
Do they really say that in the docs? Could you quote that? I have never seen such a statement and I've successfully used flat models with tree views many times. You can safely use a table model with a tree view.

Michiel
14th May 2007, 22:24
The exact words are: "Since the model provides a more specialized interface than QAbstractItemModel, it is not suitable for use with tree views, although it can be used to provide data to a QListView."

But thanks for the answer. I'll go ahead and use the table model. :)

wysota
14th May 2007, 23:03
It means that it can't make use of all its capabilities, because you can't build trees with it.

Michiel
14th May 2007, 23:16
It means that it can't make use of all its capabilities, because you can't build trees with it.

Yes. But you have to admit the quote is misleading. It could also have meant that you just can't use it with a QTreeView.

wysota
15th May 2007, 09:09
It's not misleading for me as I know the model is a subclass of a more general model that is usable with a tree. But you are right, you could interprete it in different ways.