hi to all.
This is my first post so i hope that this is the right section.
I'm going to post a little portion of my code and a fter i'll go to expose my problem
pdfviewer.h:
#ifndef PDFVIEWER_H
#define PDFVIEWER_H
#include <QMainWindow>
#include <QImage>
#include <QVector>
#include <iostream>
#include <poppler/qt4/poppler-qt4.h>
#include <QFileDialog>
namespace Ui {
class PdfViewer;
}
{
Q_OBJECT
public:
~PdfViewer();
bool setDocument
(const QString &filePath
);
void showPage(int page);
int getCurrentPage();
void setScale(double scaleFactor = 1.0);
private slots:
void on_indietroBtn_clicked();
void on_avantiBtn_clicked();
void on_comboBox_currentIndexChanged(int index);
void on_lineEdit_returnPressed();
private:
Ui::PdfViewer *ui;
int currentPage;
Poppler::Document *doc;
double scaleFactor;
QVector<qreal> scaleFactors;
};
#endif // PDFVIEWER_H
#ifndef PDFVIEWER_H
#define PDFVIEWER_H
#include <QMainWindow>
#include <QImage>
#include <QVector>
#include <iostream>
#include <poppler/qt4/poppler-qt4.h>
#include <QFileDialog>
namespace Ui {
class PdfViewer;
}
class PdfViewer : public QMainWindow
{
Q_OBJECT
public:
explicit PdfViewer(QString, QWidget *parent = 0);
~PdfViewer();
bool setDocument(const QString &filePath);
void showPage(int page);
int getCurrentPage();
void setScale(double scaleFactor = 1.0);
private slots:
void on_indietroBtn_clicked();
void on_avantiBtn_clicked();
void on_comboBox_currentIndexChanged(int index);
void on_lineEdit_returnPressed();
private:
Ui::PdfViewer *ui;
int currentPage;
Poppler::Document *doc;
double scaleFactor;
QVector<qreal> scaleFactors;
};
#endif // PDFVIEWER_H
To copy to clipboard, switch view to plain text mode
mainwindow.cpp:
....................
QString filePath
= model
->record
(index.
row()).
value("path").
toString();
PdfViewer *pdfViewer = new PdfViewer(filePath, 0);
pdfViewer->show();
....................
....................
QString filePath = model->record(index.row()).value("path").toString();
PdfViewer *pdfViewer = new PdfViewer(filePath, 0);
pdfViewer->show();
....................
To copy to clipboard, switch view to plain text mode
whit this code i can open a pdf from a path to a local file.now i have this url
http://www.ing.unisi.it/didattica/matdid/2163.pdf
which is a pdf itself.Can i open directly this file by passing it's URL to PdfViewer?
i've tried this
QUrl url
("http://www.ing.unisi.it/didattica/matdid/2162.pdf");
PdfViewer *pdfViewer = new PdfViewer(filePath, 0);
pdfViewer->show();
QUrl url("http://www.ing.unisi.it/didattica/matdid/2162.pdf");
QString filePath = url.path();
PdfViewer *pdfViewer = new PdfViewer(filePath, 0);
pdfViewer->show();
To copy to clipboard, switch view to plain text mode
but it doesn't work
error:
Error: Cannot open the specified file
Couldn't open file '/didattica/matdid/2162.pdf': File or directory not exist.
Error: Cannot open the specified file
Couldn't open file '/didattica/matdid/2162.pdf': File or directory not exist.
To copy to clipboard, switch view to plain text mode
thank to all for the replies and i want to say sorry for my bad english.
Bookmarks