这是我的代码功能:
void ReportHistory::update(void)
{
ui.output->clear();
ui.output->setCurrentFont(QFont("Arial", 8, QFont::Normal));
QString title = "My Title";
QStringList headers = QString("Header1,Header2,Header3,Header4,Header5,Header6").split(",");
QString html = QString(
"<html>" \
"<head>" \
"<meta Content=\"Text/html; charset=Windows-1251\">" \
"<title>%1</title>" \
"</head>" \
"<body bgcolor=#ffffff link=#5000A0>" \
"<p>%1</p>" \
"<table border=1 cellspacing=0 cellpadding=2>" \
"<tr bgcolor=#f0f0f0>"
).arg(title);
foreach (QString header, headers)
{
html.append(QString("<th>%1</th>").arg(header));
}
html.append("</tr>");
struct Fill
{
QString html_;
Analytics::NavHistory::History::value_type prev_;
Fill(QString html) : html_(html)
{}
void operator ()(const Analytics::NavHistory::History::value_type& entry)
{
QStringList line = (QString(
"%1|%2|%3|%4|%5|%6"
).arg(value1, 15)
.arg(value2 ? ' ' : 'C', 8)
.arg(value3, 15)
.arg(value4, 15, 'f', 4)
.arg(value5, 15)
.arg(value6, 15, 'f', 4)).split("|");
html_.append("<tr>");
foreach (QString item, line)
{
html_.append("<td bkcolor=0>%1</td>").arg(item);
}
html_.append("</tr>");
prev_ = entry;
}
};
std::for_each(history_->data().begin(), history_->data().end(), Fill(html));
html.append(
"</table>" \
"</body>" \
"</html>");
ui.output->setHtml(html);
}
在哪里:
ui.output
是一个指向 QTextEdit 的指针。
问题:ui.output
只给我看标题,而不是完整的表格,有什么问题?
谢谢。