Baso Baso - 3 months ago 45
C++ Question

How to open a .pdf file from QML?

Is there any way to open a .pdf file from QML or I have to do it in C++ via QDesktopServices , and if I used QDesktopServices would it work without any problem in Android.

Thanks.

Answer

Is there any way to open a .pdf file from QML or I have to do it in C++ via QDesktopServices

The only thing I am aware of is the following:

Qt.openUrlExternally("http://stackoverflow.com/questions/23001582/how-to-open-a-pdf-file-from-qml/23002658");

Based on the comments, it seems to work on Android

In your particular case, it would become:

Qt.openUrlExternally("path/to/my/foo.pdf");

and if I used QDesktopServices would it work without any problem in Android

The question lacks a question mark, but nitpicking aside, this oughta work. This bug was also fixed in Qt 5.2.0. That is why I asked about the version, but other than this, I am not aware of any other critical issues:

QDesktopServices::openUrl crashes Application