开发者

How to write on multiple lines in a QMessageBox in QtCreator?

开发者 https://www.devze.com 2023-03-24 00:45 出处:网络
I would like to have in a message box the following lines: name: surname: da开发者_如何转开发ta:

I would like to have in a message box the following lines:

name:
surname:
da开发者_如何转开发ta:
test:

After each : I'll programmatically fill the line. I would like to ask how can I have this structure in a QMessageBox. It is possible?

I am a beginner in Qt Creator. Currently I learned to do this:

QMessageBox noc;
            std::string s= "hello1";
            QString er = s.c_str();
            noc.setText(er);
            noc.exec()


QString str;

str = QString("name: %1\nsurname: %2\ndata: %3").arg(...).arg(...).arg(...);
QMessageBox::information(0, "Title", str);

Take a look at QMessageBox::information() and QString::arg().


just add "\n" at the end of each string...

QMessageBox noc;
QString er = tr("name: %1\nsurname: %2\ndata: %3\ntest:%4").arg(...);
noc.setText(er);
noc.exec();
0

精彩评论

暂无评论...
验证码 换一张
取 消