[Qt-interest] append non-paragraph text in QPlainTextEdit

Klaus Schneider-Zapp klaus_snd at web.de
Wed May 12 18:46:46 CEST 2010


Am Wednesday 12 May 2010 17:20:51 schrieb Robert Hairgrove:
> Klaus Schneider-Zapp wrote:
> > Hi,
> >
> > in my app I read from a serial port and append all incoming text to a
> > QPlainTextEdit to be displayed. I cannot use appendPlainText (), since
> > incoming pieces are not necessarily new paragraphs. I can use
> > insertText() but this has the following problem: If the user selects text
> > and in that moment new data comes in, the selection is deleted and
> > replaced. The brute force method to solve this would be to save the
> > currect selection and cursor position, set the cursor at the end, insert
> > the text, and restore cursor position and selection. However, this adds
> > unnecessary overhead to my program and slows it down, especially if data
> > is received at a high rate. Is there a more convenient way to solve this
> > problem?
> >
> > Thanks very much and best regards,
> > Klaus
>
> It sounds like you need to buffer the input ... have you looked at
> QDataStream and QBuffer?

Thanks for the quick suggestion. Did I understand you correctly that your 
suggestion is to buffer until a paragraph is complete? This is not really 
what I want, because I need to see the output directly. The data displayed is 
debugging output sent from a MCU, which may send progress information in form 
of continuing points, stars, and other signs, with paragraphs occuring when 
special events take place.

Regards,
Klaus



More information about the Qt-interest-old mailing list