user29893
user29893

Reputation: 43

printing text in qt mainwindow.ui window in my widget application

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

Answers (2)

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");

Upvotes: 1

bogdyname
bogdyname

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

Related Questions