qt pdf浏览器
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QDir>
#include <QWebEngineView>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
QWebEngineView *view;
QString pdfUrl;
QString pathToPDFjs = QString("file:///%1/%2")
.arg(QDir::currentPath())
.arg("3rdParty/pdfjs-1.7.225-dist/web/viewer.html");
pdfUrl = QString("file:///%1/%2").arg(QDir::currentPath()).arg("Concurrency_with_Modern_C++.pdf");
view = new QWebEngineView();
setCentralWidget(view);
//参数不能输错
QUrl url = QUrl::fromUserInput(pathToPDFjs + QString("?file=") + pdfUrl);
view->load(url);
}
MainWindow::~MainWindow()
{
delete ui;
}