1

I filled my QtextStream textStream object, already. When it does not end with an "}", I want to append one "}" in that case:

  QString fullText = textStream.readAll();
  if( !fullText.trimmed().endsWith("}") )
  {
    QString lastBracket("\n}");
    textStream << lastBracket;
  }

But after this, my TextStream is just "}" ? So the readAll flushes the TextStream ? How could I solve that elsewise?

Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103
  • "after this, my TextStream is just `}`" - how do you know that? Show the code, ideally a `Q_ASSERT` that demonstrates how you check for this condition. There is no such thing as "flushing" a `QTextStream` in the sense of removing its data - not as far as I know. – Kuba hasn't forgotten Monica Sep 02 '15 at 15:03
  • There's no way of answering this without you showing some code that demonstrates *the entire thing*: how you set up the device, how you set the text stream on it, how you then append the bracket, and finally how you verify that *only* the bracket is there. *As always, please edit your question with the missing details, don't comment here unless something is unclear as to what is asked of you*. – Kuba hasn't forgotten Monica Sep 02 '15 at 15:05

0 Answers0