Adding data to Frozen Column QTreeWidget
-
I have created a frozen column
QTreeWidget(first column is not scrollable), by sharing model with aQTreeViewand usingviewport->stackUnder.-
Any child row is to be added only when parent is expanded. This works fine for the frozen
QTreeView, but any data in other columns do not get displayed in the underlyingQTreeWidget, so all other columns are blank for child rows. (Verified that the childQTreeWidgetItemdoes contain the data for other columns) -
The data added does not get displayed in-order in the widget i.e. even though I insert with
QTreeWidget::addTopLevelItemin a loop, the actual output does not match the order in which the items are added.
What is the correct way of writing this? Also, I tried using
QTreeViewandQAbstractItemModelbut that further complicates the model and could not get it working. Is writing a dedicated model the only way? -
-
Never mind, I solved both of the problems.
- Issue was with hooking up event handlers and from where child items were being populated.
- Default sorting was enabled, which was leading to this.
-
So you made something like
http://doc.qt.io/qt-5/qtwidgets-itemviews-frozencolumn-example.htmlWith tree views ?
Good work :)
-
Yes inspired from that example, though some modification specific to
QTreeView, but everything now works except for few hiccups regarding child row visibility. Posted a separate question.