Unsolved QPlainTextEdit resizeEvent not triggered on making document's blocks visible/invisible
-
I am using QT 4.8 to implement a class (derived from QPlainTextEdit) to log messages, which offers the functionality of folding/unfolding a set of messages. Each message is a QTextBlock.
class MessageLog : public QPlainTextEdit { foldOrUnfoldTextBlocks(....) { // folds/unfolds a set of text blocks by QTextBlock's setVisible() API document()->documentLayout()->requestUpdate(); } }
The function
foldOrUnfoldTextBlocks()
does not trigger theresizeEvent()
ofMessageLog
which leads to some messages being cut at the bottom on unfolding and leaves extra space at the bottom on folding.
How isresizeEvent()
supposed to be triggered on making text blocks visible/invisible in the document? -
Hi and welcome to devnet,
What exactly are you trying to resize for ?
-
Hi SGaist,
The resize of
QPlainTextEdit
is required in following two scenarios:- On making some of the invisible
QtextBlocks
visible, the size of the document changes. To accommodate the extra blocks, theQPlainTextEdit
needs to be resized otherwise some of the blocks will be cut at the bottom - On making visible blocks invisible, extra white space will be left at the end in
QPlainTextEdit
- On making some of the invisible
-
Is your QPlainTextEdit in a layout ?
-
@SGaist
QPlainTextEdit
is in aQStackedWidget
which is in aQVBoxLayout
-
In that case, the resize of QPlaintTextEdit is managed by QVBoxLayout which manages QStackedWidget which manages your QPlainTextEdit.