Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. using QAxWidget Adobe PDF Reader with qDebug()<<pdf->dynamicCall("Print()"); I received: QVariant(Invalid)
QtWS25 Last Chance

using QAxWidget Adobe PDF Reader with qDebug()<<pdf->dynamicCall("Print()"); I received: QVariant(Invalid)

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 163 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    philxxx609
    wrote on last edited by
    #1

    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!!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved