Reputation: 1354
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.
Upvotes: 4
Views: 5939
Reputation: 503
You can do this from QML using the V-Play FileUtils: https://v-play.net/doc/fileutils/
fileUtils.openFile("<path to pdf file>")
Here is an example code that downloads a PDF from the web and opens it using the default application on Android and iOS: https://v-play.net/web-editor/?snippet=ce64a995
Upvotes: 0
Reputation: 53175
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
Upvotes: 7