[Qt-interest] QPlainTextEdit has broken layout after hide(), show()

Kevin Funk krf at gmx.de
Tue Jun 21 21:24:07 CEST 2011


Tuesday 21 June 2011, Nikos Chantziaras <realnc at arcor.de>:
> I came across a strange glitch with QPlainTextEdit: When I modify it
> with insertPlainText() while the QPTE is hidden and then show() it, the
> contents are all messed up and will only show correctly is the user
> resizes the widget.  Calling update() after show() does not help.
> Calling document()->setModified() and/or document()->markContentsDirty()
> doesn't help either.
> 
> Any solutions to this?  And should this be considered a bug that should
> be reported?

Hey there,

I think I had to solve the same issue just recently:

You could try this code to force a re-layout of the QTPE contents:
QEvent e(QEvent::FontChange);
QApplication::sendEvent(textEdit, &e);

This is from [1].

I personally think this should be considered a bug in 
QTextDocument/QAbstractTextDocumentLayout.

[1] http://lists.trolltech.com/qt4-preview-feedback/2005-02/thread01030-0.html

Greets

-- 
Kevin Funk



More information about the Qt-interest-old mailing list