开发者

QTreeWidget set height of each row depending on content

开发者 https://www.devze.com 2022-12-27 13:04 出处:网络
I want开发者_JAVA百科 to make editable cells with multi-lines content in QTreeWidget and I use for this purpose QPlainTextEdit as a delegate. I need to set proper size to all rows that switching betwe

I want开发者_JAVA百科 to make editable cells with multi-lines content in QTreeWidget and I use for this purpose QPlainTextEdit as a delegate. I need to set proper size to all rows that switching between editing and displaying went smooth, without any visible changes.

rect = textEdit.blockBoundingRect(textEdit.firstVisibleBlock())
  • With this I can find out the height I need to set for the row, but I missing the place where I can do it.

How can I set proper height to QTreeWidget's rows on initialization stage and how to handle it's changes?


You need to reimplement delegate's sizeHint(). It will automatically handle row's height and width. And note, that QTreeWidget::uniformRowHeight property must be false in this case, though it will slow tree element rendering if it contains many rows.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号