QVBoxLayout *mainLayout = new QVBoxLayout;
QUrl chtmlPath;
chtmlPath.setUrl("aboutus.html");
QString filepath = "F:/resource/html";
setAttribute(Qt::WA_DeleteOnClose);
setAttribute(Qt::WA_GroupLeader);
QTextBrowser *textBrowser = new QTextBrowser;
textBrowser->setReadOnly(true);
textBrowser->setContextMenuPolicy(Qt::NoContextMenu);
textBrowser->setAcceptRichText(true);
textBrowser->setAutoFormatting(QTextEdit::AutoAll);
//设置搜索的路径和图片的路径
//主要是这一步,指定html相对路径,和图片加载的相对路径路径,要和html中设置一样
textBrowser->setSearchPaths(QStringList() << filepath << ":/images");
QStringList stringList = textBrowser->searchPaths();
textBrowser->setSource(chtmlPath);
mainLayout->addWidget(textBrowser);