[英]How to write on multiple lines in a QMessageBox in QtCreator?
I would like to have in a message box the following lines: 我希望在消息框中包含以下几行:
name:
surname:
data:
test:
After each :
I'll programmatically fill the line. 每次之后
:
我将以编程方式填写该行。 I would like to ask how can I have this structure in a QMessageBox. 我想问一下如何在QMessageBox中使用此结构。 It is possible?
有可能的?
I am a beginner in Qt Creator. 我是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() . 看一下QMessageBox :: information()和QString :: arg() 。
just add "\\n" at the end of each string... 只需在每个字符串的末尾添加“ \\ n” ...
QMessageBox noc;
QString er = tr("name: %1\nsurname: %2\ndata: %3\ntest:%4").arg(...);
noc.setText(er);
noc.exec();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.