PDA

View Full Version : Open a PDF with Qt 4.2.0 OpenSource



xgoan
14th December 2006, 10:38
Hi,

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

Bye

wysota
14th December 2006, 10:54
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.

xgoan
14th December 2006, 11:28
ActiveQt is in Open Source edition?

wysota
14th December 2006, 12:03
No, it's not, but you don't have to use ActiveQt to use ActiveX, so the way is still open.

Dark_Tower
16th December 2006, 01:12
That's how I've done it on Windows:

if (!QProcess().startDetached(pathPDF, params))
QMessageBox::warning(this, "Application Name", "Cannot open the file",
"&Accept", QString::null, QString::null, 0, 0);

wysota
16th December 2006, 01:38
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.

Dark_Tower
16th December 2006, 11:51
That's how I've done it on Windows:

if (!QProcess().startDetached(pathPDF, params))
QMessageBox::warning(this, "Application Name", "Cannot open the file",
"&Accept", QString::null, QString::null, 0, 0);

Sorry but that's not exactly how I did it. Here is the correct code:

if ((long)ShellExecuteW(0, 0, reinterpret_cast<const WCHAR *>(pathDocPDF.utf16()), 0, 0,
SW_SHOWNORMAL) <= 32)
QMessageBox::warning(this, "Pre-Visualització","error trying to open the file",
"&Accept", QString::null, QString::null, 0, 0);


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