Results 1 to 7 of 7

Thread: Open a PDF with Qt 4.2.0 OpenSource

  1. #1
    Join Date
    Jul 2006
    Posts
    126
    Thanks
    17
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Open a PDF with Qt 4.2.0 OpenSource

    Hi,

    is there a way to open PDF files in a Qt application?

    Bye

  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 a PDF with Qt 4.2.0 OpenSource

    If you want to display it, you can use activeX on Windows or XEmbed on Unix. You can also use some tool to convert pdf to some other format (like html) which Qt can handle.

  3. #3
    Join Date
    Jul 2006
    Posts
    126
    Thanks
    17
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Open a PDF with Qt 4.2.0 OpenSource

    ActiveQt is in Open Source edition?

  4. #4
    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 a PDF with Qt 4.2.0 OpenSource

    No, it's not, but you don't have to use ActiveQt to use ActiveX, so the way is still open.

  5. #5
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Open a PDF with Qt 4.2.0 OpenSource

    That's how I've done it on Windows:
    Qt Code:
    1. if (!QProcess().startDetached(pathPDF, params))
    2. QMessageBox::warning(this, "Application Name", "Cannot open the file",
    3. "&Accept", QString::null, QString::null, 0, 0);
    To copy to clipboard, switch view to plain text mode 

  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 a PDF with Qt 4.2.0 OpenSource

    You can even use QDesktopServices to do that, but you won't display a pdf file inside your application this way, just run an external pdf browser.

  7. #7
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Open a PDF with Qt 4.2.0 OpenSource

    Quote Originally Posted by Dark_Tower View Post
    That's how I've done it on Windows:
    Qt Code:
    1. if (!QProcess().startDetached(pathPDF, params))
    2. QMessageBox::warning(this, "Application Name", "Cannot open the file",
    3. "&Accept", QString::null, QString::null, 0, 0);
    To copy to clipboard, switch view to plain text mode 
    Sorry but that's not exactly how I did it. Here is the correct code:
    Qt Code:
    1. if ((long)ShellExecuteW(0, 0, reinterpret_cast<const WCHAR *>(pathDocPDF.utf16()), 0, 0,
    2. SW_SHOWNORMAL) <= 32)
    3. QMessageBox::warning(this, "Pre-Visualització","error trying to open the file",
    4. "&Accept", QString::null, QString::null, 0, 0);
    To copy to clipboard, switch view to plain text mode 

    it only opens the PDF doc with the default application installed on your system

Similar Threads

  1. Replies: 3
    Last Post: 7th October 2015, 19:43
  2. QDesktopServices open url & local file & pdf or doc
    By patrik08 in forum Qt Programming
    Replies: 9
    Last Post: 14th April 2012, 04:42
  3. Replies: 3
    Last Post: 25th August 2010, 12:39
  4. Replies: 11
    Last Post: 24th March 2006, 06:40

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.