2

I know that Label is what i use to set some text in a single line, however I want to print multiple lines, more specifically is a loop foreach that will print all the data the user entered previously. There is some way?

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
user29893
  • 31
  • 1
  • 6

2 Answers2

1

Create object of QTextEdit. Set QTextEdit::setReadOnly(true); If you need only to show data of user in window.

You can past your text in cycle via html: QTextEdit::setHtml(const QString &text).

Or if it simple text then use slot: QTextEdit::insertPlainText(const QString &text)

More:

QTextEdit::setText(const QString &text)
QTextEdit::setPlainText(const QString &text)

Look here: https://doc.qt.io/qt-5/qtextedit.html

bogdyname
  • 358
  • 2
  • 10
1

yes, there is a way to do that...

make sure you set the "wordWrap" attribute in the label to true... enter image description here

and new lines are scaped using \n

ui->myLabel->setText("asdasda\n...Asdasdasdasdasd\n...--Docker\nno\Mac");
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97