resizing row's height in QTreeWidget/QTreeView

Posted by serge on Stack Overflow See other posts from Stack Overflow or by serge
Published on 2010-04-16T14:14:58Z Indexed on 2010/04/19 3:33 UTC
Read the original article Hit count: 1022

Filed under:
|

Hi everyone,

I have some problems with sizing row's height in QTreeWidget. I use QStyledItemDelegate with QPlainTextEdit. During editing text in QPlainTextEdit i check for changes with a help of:

rect = self.blockBoundingRect(self.firstVisibleBlock())

and if text's height changes i resize editor size and need row in QTreeWidget also resizing. But i don't know how to inform TreeWidget or a Delegate about changes. I tried to initialize editor with index, that i could use in a future, but Delegate creates new editor every time and i failed to use signals. Also I used following function to catch resize event, but it' doesn't:

bool QAbstractItemDelegate::editorEvent ( QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index )

How can i bound editor's size changes with TreeWidget?

And one more thing, by default all items (cells) in TreeWidget have -1 or some big value as default width. I need whole text in cell to be visible, so how can i limit cells width only by visible range and make it expand in height? I want for it the same behavior as in instance a table in MSWord.

Thank you in advance, Serge

© Stack Overflow or respective owner

Related posts about qt

Related posts about pyqt