Results 1 to 2 of 2

Thread: Qurl+poppler

  1. #1
    Join Date
    Jun 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Qurl+poppler

    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:

    Qt Code:
    1. #ifndef PDFVIEWER_H
    2. #define PDFVIEWER_H
    3.  
    4. #include <QMainWindow>
    5. #include <QImage>
    6. #include <QVector>
    7. #include <iostream>
    8. #include <poppler/qt4/poppler-qt4.h>
    9. #include <QFileDialog>
    10.  
    11.  
    12. namespace Ui {
    13. class PdfViewer;
    14. }
    15.  
    16. class PdfViewer : public QMainWindow
    17. {
    18. Q_OBJECT
    19.  
    20. public:
    21. explicit PdfViewer(QString, QWidget *parent = 0);
    22. ~PdfViewer();
    23. bool setDocument(const QString &filePath);
    24. void showPage(int page);
    25. int getCurrentPage();
    26. void setScale(double scaleFactor = 1.0);
    27.  
    28. private slots:
    29. void on_indietroBtn_clicked();
    30. void on_avantiBtn_clicked();
    31. void on_comboBox_currentIndexChanged(int index);
    32.  
    33. void on_lineEdit_returnPressed();
    34.  
    35. private:
    36. Ui::PdfViewer *ui;
    37. int currentPage;
    38. Poppler::Document *doc;
    39. double scaleFactor;
    40. QVector<qreal> scaleFactors;
    41.  
    42. };
    43.  
    44. #endif // PDFVIEWER_H
    To copy to clipboard, switch view to plain text mode 


    mainwindow.cpp:

    Qt Code:
    1. ....................
    2.  
    3. QString filePath = model->record(index.row()).value("path").toString();
    4. PdfViewer *pdfViewer = new PdfViewer(filePath, 0);
    5. pdfViewer->show();
    6.  
    7. ....................
    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

    Qt Code:
    1. QUrl url("http://www.ing.unisi.it/didattica/matdid/2162.pdf");
    2. QString filePath = url.path();
    3. PdfViewer *pdfViewer = new PdfViewer(filePath, 0);
    4. pdfViewer->show();
    To copy to clipboard, switch view to plain text mode 

    but it doesn't work

    error:
    Qt Code:
    1. Error: Cannot open the specified file
    2. 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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qurl+poppler

    You need to download the file first. You can use QNetworkAccessManager for that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Bulding a PDF Plugin for qtWebKit using poppler
    By qt-liviu in forum Qt Programming
    Replies: 1
    Last Post: 8th October 2012, 14:15
  2. Poppler
    By maider in forum General Programming
    Replies: 1
    Last Post: 13th July 2010, 19:13
  3. Poppler and Qt embedded
    By webquinty in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 29th June 2010, 16:48
  4. Poppler for windows
    By maider in forum Installation and Deployment
    Replies: 0
    Last Post: 11th March 2010, 11:01
  5. Problem to build poppler under Windows
    By Lykurg in forum Installation and Deployment
    Replies: 0
    Last Post: 12th November 2008, 17:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.