Results 1 to 10 of 10

Thread: Open an external file from qt

  1. #1
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Open an external file from qt

    Hello,

    I'm trying to open a .pdf file from qt. I have develop the following code to achieve my goal:

    Qt Code:
    1. #include <QDesktopServices>
    2. #include <QUrl>
    3.  
    4. exercise::exercise(QWidget *parent)
    5. : QWidget(parent)
    6. {
    7. ui.setupUi(this);
    8. connect(ui.open,SIGNAL(clicked()),this,SLOT(openDocument()));
    9. }
    10.  
    11. exercise::~exercise()
    12. {
    13.  
    14. }
    15.  
    16. void exercise::openDocument()
    17. {
    18. desk.openUrl(QUrl("file://C:/a.pdf"));
    19. }
    To copy to clipboard, switch view to plain text mode 


    Can someone help me? i have read the post about this thread, but i'm not capable to solve the problem.

  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: Open an external file from qt

    Ok, but what exactly is the problem?

    BTW. Take a look at QUrl::fromLocalFile()
    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.


  3. #3
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Open an external file from qt

    the problem is that when I pushed the button no file has shown.

  4. #4
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Open an external file from qt

    i have get it!

    but is any function in qt to open a pdf without havin installing into my software the adobe reader?

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Open an external file from qt

    I dont think so.. though I guess there are 3rd party libraries to do that

  6. #6
    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: Open an external file from qt

    There is poppler but I don't know if it supports Windows.
    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.


  7. #7
    Join Date
    Mar 2008
    Location
    France
    Posts
    149
    Thanks
    2
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Open an external file from qt

    Qt is not shipped with a pdf viewer, so to view pdf files:
    you can embed adobe ActiveX control in your app,
    or fires up the adobe reader ,
    or use some third parties libraries (Poppler is the most known).
    Last edited by toutarrive; 12th March 2010 at 09:41.

  8. #8
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Open an external file from qt

    ok, i will try with poppler.

    one question more please! Nowadays I want to see the .pdf into a text edit but problems occured. why? i have written this comand:
    ui.textEdit->desk.openUrl(QUrl("a.pdf"));

    thanks

  9. #9
    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: Open an external file from qt

    This is not even a proper C++ syntax... And even if it was, you can't expect an application framework to do everything you could imagine it would be good to have. You can't place PDF files into QTextEdit. Please launch Qt Assistant, type in "QDesktopServices" in the index tab and read the description of what the class does.
    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.


  10. #10
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Open an external file from qt

    you are right! i cannot use it-

Similar Threads

  1. How to Open External Links?
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 18th March 2008, 06:47
  2. Database: How to use an external file?
    By goes2bob in forum Newbie
    Replies: 10
    Last Post: 23rd January 2008, 14:07
  3. open an external links
    By sudheer in forum Qt Tools
    Replies: 4
    Last Post: 17th January 2008, 04:50
  4. Replies: 2
    Last Post: 14th January 2008, 18:09
  5. How to open external page link using tabwidget
    By jyoti in forum Qt Programming
    Replies: 2
    Last Post: 13th November 2006, 10:43

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.