QTreeView can span children's items to a new item
-
Hi, all, QTreeView has the ability to span children's items like QTableView::setSpan? For example, below the picture, I want to span the item "111", "222", "333" to a new item.But I can't find the QTreeView api to do this work. Do you have a good idea? Thanks a lot.
-
@jinming
The only spanning available is void QTreeView::setFirstColumnSpanned(int row, const QModelIndex &parent, bool span). That would be for just the case where you want first column to span all other columns and they don't get shown.Otherwise you have to do quite some work (delegate or subclassing) to do this, maybe suggest you follow @SGaist's request for a drawing so we're sure what's wanted.
-
@SGaist Hi, I want to make a UI to display signal which is decoded by CAN data, like the below picture shows.
It has the header "Time | Chn | ID | Name | ...." like QTreeView header, but the children has some difference, example, children item "EngTemp 86 degC 44" has the space between column "Time | Chn | ID | Name", I think this is suitable, because the information("EngTemp 86 degC 44") is too big. Does QT has the method to make it. -
@jinming so those are in facts data unrelated to the headers above them.
You might be able to do something with a custom QStyledItemDelegate
-
@SGaist I read the qt example "Qt\Examples\Qt-6.5.1\widgets\itemviews\stardelegate". It uses StarDelegate which subclass QStyledItemDelegate, but the staritem size is controled by header. How a custom QStyledItemDelegate can expanding the item size that dones't control by header?