简体   繁体   English

根据QTextedit显示文本

[英]Display the text according to QTextedit

in this question i asked how to split text by whitespace, now i split it, but now i can't display this text in QTextEdit. 在这个问题中,我问如何用空格分割文本,现在我将其分割,但是现在我无法在QTextEdit中显示此文本。 I make so: 我这样做:

  QStringList list = line.split(QRegExp("\\s+"));

  for (int i = 0; i < list.count(); i++){
      table.push_back(list[i]);

      this->ui->textEdit->setText(table[i]); //output text in qtextedit
  }

But i see clean textedit after that. 但是之后我看到干净的textedit。 But if i make for example: 但是如果我举个例子:

this->ui->textEdit->setText(table[2]);

I see third word in QTextEdit. 我在QTextEdit中看到第三个单词。 What's wrong? 怎么了?

Thank you. 谢谢。

What type is table ? table是什么类型? setText only takes a QString, which means you'll need to build a big string of your split string elements and set the Text to that. setText只需要一个QString,这意味着您需要构建一个很大的字符串分割字符串并将Text设置为该字符串。

Alternatively, you could clear the QTextEdit and append every string in table . 或者,您可以清除QTextEdit并在table附加每个字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM