2017-05-15 5 views
0

메시지에 테두리를 설정하려고했지만 작동하지 않습니다. 당신은 문제가 어디에 있는지 지적 할 수 있습니까?QMessageBox에서 메시지 테두리를 설정하는 방법은 무엇입니까?

QMessageBox msg(this); 
msg.setWindowModality(Qt::WindowModal); 
msg.setWindowTitle(QLatin1String("Notice")); 
msg.setTextFormat(Qt::RichText); 
msg.setText("<html><head/><body><p>The reason of error is :</p><p><span style=\"border : 1px solid;\"><i> There is no data </i></span></p></body></html>"); 
msg.setStandardButtons(QMessageBox::Ok); 
msg.setIcon(QMessageBox::Icon::Warning); 
msg.exec(); 

결과적으로 이탤릭체가 작동하지만 테두리가 작동하지 않습니다.

enter image description here

답변

1

당신은 또한하여 span을 다른 QLabel에 "There is no data"를 텍스트를 넣어

yourReasonLabel.setStyleSheet("border: 1px solid black;"); 

를 사용하거나 대체 할 수 border-colorborder-style
를 사용하려고 Supported HTML Subset Qt는
의 확인 a table 및 추가 css :

msg->setText("<html><head/><body>" 
      "<p>The reason of error is :</p>" 
      "<table style='border-style: solid; border-color: orange;border-width: 1px;'>" 
      "<tr><td><i> There is no data </i></td></tr>" 
      "</table></body></html>"); 
+0

감사합니다. 나는'border-style'을 사용하려고했지만 작동하지 않습니다. 그리고 나는 테두리를 위해 픽셀을 설정하는 방법을 모른다. border-width는 없다. – gnase

+0

그래, 나도 생각해 봤어.이 경우에'msg'에 라벨을 추가하는 방법을 모르겠다. – gnase

+0

@gnase,'''QDialog'''를 서브 클래스 화하여 자신의''MessageBox' '' –

관련 문제