2011-08-01 38 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();