关于Qt打印html文件的问题
QString fileContent = "";
QFile file1("3.html");
if(file1.open(QIODevice::ReadOnly))
{
QTextStream fs(&file1);
fileContent = fs.readAll();
file1.close();
}
QPrinter printer(QPrinter::HighResolution);
QPrintDialog printDialog(&printer, this);
if (printDialog.exec())
{
QTextDocument textDocument;
textDocument.setHtml(fileContent);
textDocument.print(&printer);
}