#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QString>
#include <QFileDialog>
#include <QPalette>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QString path = QFileDialog::getOpenFileName(this, tr("打开一个文本"), ".", tr("(*.pdf)"));
doc = Poppler::Document::load(path);
int index = 0;
Poppler::Page* pdfPage = doc->page(index); // Document starts at page 0
if (pdfPage == 0) {
// ... error message ...
return;
}
// Generate a QImage of the rendered page
QImage image = pdfPage->renderToImage(72,72 , -1, -1, -1, -1);
if (image.isNull()) {
// ... error message ...
return;
}
QPalette palette;
palette.setBrush(this->backgroundRole(),QBrush(image));
this->setPalette(palette);
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
QT使用Poppler-qt5操作PDF.zip (6个子文件)
QT使用Poppler-qt5操作PDF
mainwindow.ui 654B
mainwindow.cpp 936B
main.cpp 205B
untitled3.pro.user 18KB
untitled3.pro 785B
mainwindow.h 406B
共 6 条
- 1
迷路君
- 粉丝: 12
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页