对于我的程序,我正在为 about 部分做一个 QMessageBox,并导入一个 html 文件来设置所述框的布局:
// Program.cpp
QMessageBox about;
about.setWindowTitle(tr("About"));
// Enable the HTML format.
about.setTextFormat(Qt::RichText);
// Getting the HTML from the file
std::ifstream file("html/about.html");
std::string html, line;
if (file.is_open())
{
while (std::getline(file, line))
html += line;
}
about.setText(html.c_str());
about.exec();
about.html 是这样的:
<!-- about.html -->
<div>
<h1>The Program</h1>
<p> Presentation </p>
<p> Version : 0.1.2 </p>
<p> <a href="www.wipsea.com">User Manual</a> </p>
<h4>Licence Agreement</h4>
<p style="border: 1px solid black; overflow: y;">
Law thingy, bla and also bla, etc ...
</p>
</div>
问题是我不知道什么是可能的,什么是不可能的。
例如,我想将许可协议放在带有边框和溢出的文本区域中。h1 和 h4 有效,但许可协议的样式无效。
所以许可协议只是纯文本。
有没有办法在 QMessageBox 中设置 html 的样式?