[Qt-interest] QPlainTextEdit has broken layout after hide(), show()
Nikos Chantziaras
realnc at arcor.de
Wed Jun 22 08:00:54 CEST 2011
On 06/22/2011 08:53 AM, Nikos Chantziaras wrote:
> On 06/21/2011 10:24 PM, Kevin Funk wrote:
>> 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?
>>
>> 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
>>
>
> Doesn't work, unfortunately.
I just discovered that QTextEdit does not have this problem at all.
Only QPlainTextEdit. With QTextEdit, not even sending a FontChange
event is needed; it works just fine without it.
So I guess I'm switching to QTextEdit for the application's log message
window. I hope it's not using too much memory compared to QPlainTextEdit.
More information about the Qt-interest-old
mailing list