tags:

views:

84

answers:

1

Hi to all, 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. 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. But if i make for example:

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

I see third word in QTextEdit. What's wrong?

Thank you.

+1  A: 

What type is 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.

Alternatively, you could clear the QTextEdit and append every string in table.

Stefan Kendall
table has QVector<QString> type
shk
@Stefan thank you very much, you very helped me!This is work:this->ui->textEdit->append(list[i]);
shk