Reputation: 43
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?
Upvotes: 2
Views: 429
Reputation: 48297
yes, there is a way to do that...
make sure you set the "wordWrap" attribute in the label to true...
and new lines are scaped using \n
ui->myLabel->setText("asdasda\n...Asdasdasdasdasd\n...--Docker\nno\Mac");
Upvotes: 1
Reputation: 374
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
Upvotes: 1