using QAxWidget Adobe PDF Reader with qDebug()<<pdf->dynamicCall("Print()"); I received: QVariant(Invalid)
Unsolved
General and Desktop
-
Hello guys,
Why I can not print with pdf->dynamicCall("Print()");?
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include "qdebug.h" //#include "QPushButton" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); pdf = new QAxWidget(this); if(!pdf->setControl("Adobe PDF Reader"))//("Microsoft Web Browser") QMessageBox::critical(this, "Error", "Make sure you have Adobe Reader (and its ActiveX) installed!"); qDebug() << pdf->control(); // setCentralWidget(pdf); pdf->setGeometry(10,10,500,500); currentPage=1; } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { pdf->dynamicCall("LoadFile(QString)", QDir::toNativeSeparators(QFileDialog::getOpenFileName(this, "Open PDF File", QDir::currentPath(), "PDF Documents (*.pdf)"))); pdf->dynamicCall("SetCurrentPage(int)",currentPage); } void MainWindow::on_pushButton_2_clicked() { currentPage=currentPage+1; pdf->dynamicCall("SetCurrentPage(int)",currentPage); qDebug()<<pdf->dynamicCall("Print()"); }
mainwindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <ActiveQt> QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); QAxWidget *pdf; int currentPage; private slots: void on_pushButton_clicked(); void on_pushButton_2_clicked(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
thanks for your help!!