Text after "
In the following example, each child is considered to have 2 columns, although the item is only 1 column.
(MyTreeModel is a subclass of QAbstractItemModel.)
Integrate MyTreeModel :: columnCount (constant QModelIndex & rParent / * = QModelIndex () * /) static {if (RParent.isValid ()) {Return 2; } And {return1; }}
In the following example, QTreeView display the column for 2 items for parent items and 1 child items, as expected.
Integrate MyTreeModel :: columnCount (Const QModelIndex and rparent / * = QModelIndex () * /) const {if (rparent.isValid ()) {return1; } And {return2; }}
It seems that the column number of the hair objects is limited by the column number of its original item. Is this standard behavior? Am I doing something wrong?
I checked the source code (currently not working) and found the answer as follows:
- I checked the method there I used the line
D-> title-> Setmodel (model); Found
. Header that you want - , this is
QHeaderView
. - Then check the method
- Once the connection is made:
QObject :: disconnect (D> model, hint (columnsInserted (QModelIndex, int, int)), this , Slots (sectionsInsterted (QModelIndex, int, int));
The slot method - The last thing I did was read
Looks like I've got it there:
< Code> Zero QHeaderView :: sectionsInstated (constant QModelIndex & parent, integer logicalFirst, integer logicalLast) {Q_D (QHeaderView); If (parent! = D-> route) returns; // We only handle variations in the top level
Therefore only top level items have an effect on the number of columns.
Comments
Post a Comment