2011-08-01 133 views
2

我想在一个消息框,有下面几行:如何在QtCreator中使用多行QMessageBox?

name: 
surname: 
data: 
test: 

每个":" i'll programatically fill the line.我想问我怎么能在一个MessageBox有这个结构之后。有可能的? 或 我是Qt Creator的初学者。目前我学会了这样做:

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

Thx,感谢!

回答

2

,只需加上 “\ n” 在每一个字符串的结尾......

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