[Qt-interest] QPlainTextEdit and Scrolling/Highlighting

Peter Kluger pkl at simpack.de
Tue Jan 19 12:00:56 CET 2010


Dear Qt-Community,

 currenty i am trying to implement an Message Output Widget which should 
behave like an ordinary Output-Log as seen in several IDEs like 
QtCreator/Eclipse/MsVS.
Everything works very fine and working well, except when the user wants 
to scroll or highlight a phrase, while the widget prints new output.

Because i cant use the append function (Don't want the newline it comes 
with!!), i use either setPlainText() or insertPlainText() and move the 
Cursor to the End before inserting and QTextCursor::atEnd() is true. But 
what to do at the other cases ?

My problem is that there doesn't seem to be an easy way to ensure the 
Position of the QPlainTextEdit to stay the same when the user interferes.
When try to set the Position of the TextCursor to the orignial Position 
after new prints occured, it will jump to that position but only when 
the user clicks/highlights the new position in the Text. But scrolling 
wont affect this and therefore its not a good solution for that. Working 
with the scroll position from QAbstractScrollArea wont help either, 
because when keeping the old scroll position wont be the same text 
position after inserting. And to make things worse, it would be nice if 
the highlighted text will stay highlighted afterwards, but i can see how 
this wont work when the complete text is resetted by setPlainText() and 
must be implemented manually.

I really think i am missing some special function i didnt found yet 
within the docu which actually forces the TextEdit to stay where suppose 
to stay from the user perspective.
Maybe someone out there had the same problem and a good idea i could 
work with!

Thanks for reading and in advance for your help!

-- 
Mit freundlichen Grüßen / Kind regards,

Peter Kluger
_______________________________________________________________________
 
Kluger Peter
Development                        SIMPACK AG
 
Phone:  + 49 8105 77266-62         Friedrichshafener Strasse 1
Fax:    + 49 8105 77266-11         82205 Gilching, Germany
E-Mail: peter.kluger at simpack.de    info at simpack.de
Web:    www.simpack.com

Simulation Software SIMPACK - Consulting - Training 
_______________________________________________________________________

Executive Board: Dr. Alexander Eichberger, Dr. Lutz Mauer; 
Chair of Supervisory Board: Silvia Förster (CPA); 
Commercial Register München HRB 181 229 





More information about the Qt-interest-old mailing list