How to open a .pdf file from QML? - c++

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.

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

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

Related

Why Qt remove QFtp library start from Qt5?

I just want to know why Qt remove QFtp start from Qt version 5.
Of course I can still install QtFtp manually on Qt5 but I cannot find any official answer about why they remove this library. For now, I should use QNetworkAccessManager, but it's having limited feature.
Thank you!
Edit:
More explanation about this sentence "... I should use QNetworkAccessManager, but it's having limited feature."
For example, I can get list of the content from FTP server using QtFtp, but I cannot do this with QNetworkAccessManager.

Add GUI to a QT Project with Arduino

So here is my question I have been trying to create a small "software" which would control my arduino card. For this I decide to use qt so I used this tutorial to add arduino to qt :
http://www.lucidarme.me/?p=3287
I am very sorry the page is only in French. I basicly get 3 files config files and includes for my arduino. And a Makefile. The problem I have is that I want to add GUI such as Windows but whenever I add a gui file to my project it says it cannot find the "QMainWindow". However I think the problem is deeper and that it doesn't find any Qt class.
I think this is because I don't have any pro files but I tried adding one and it didn't work. I hope you guys understood my problem I am very new to QT ...
Thank you !
The GUI project is completely unrelated to anything Arduino. The page you linked to shows how to use Qt Creator as an IDE to work on Arduino projects, as a replacement to the Arduino IDE. This has nothing to do with GUIs or Qt, you'd be reusing Qt Creator as a general-purpose IDE that it is.
What you need and want is to create a standard Qt project in Qt Creator and go from there. You can also leverage Qt to "simulate" Arduino code without running real Arduino hardware, see this answer for an example.

How to use QVirtualKeyboard plugin without using QML?

I have X_Compiled Qt for BeagleBone Black and everything works fine. I've compiled Qt virtual keyboard plugin and I can load keyboard example on the device. I want to use this virtual keyboard in my C++ app. Can anyone show me the right way to do so?
I've also downloaded a plugin and compiled it but I don't know how to use it. Can any one tell me how to use Qt plugins like the two I mentioned above?
first of all make sure that the plugin is in the plugin folfer of Qt installation path and in main file add this line before creating QApplication object.
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));

How to use QtWebview for Google Maps

Basically I want to use it for googlemaps but at the moment I can't even get it to compile a simple web page.
I'm using the latest version of Qt creator but the documentation just seems out of date
i have dragged the widget onto my form and set its url to google.com (just for testing purposes)
and when i hit compile i get loads of unresolved external symbol errors, I don't know what to include to use this I just assumed drag and drop the widget and I'm good to go, however this isn't the case.
Any ideas?
EDIT: For Qt 4.x, this is what you do:
Go into your .pro file and include the right module for QtWebKit.
http://qt-project.org/wiki/QtWebKit
QT += webkit
And here is an example you can find in the welcome pages of Qt Creator if you want more:
http://qt-project.org/doc/qt-4.8/webkit-fancybrowser.html
Good luck; hope that helps. And btw, I just tested it with Google Maps, and it renders fine with Qt 4.8.4 on Win 7.
EDIT: For Qt 5.x+, this is what you do:
QT += webkitwidgets
Like it shows in the .pro file of any of the examples here:
http://qt-project.org/doc/qt-5.0/qtwebkitexamples/webkitwidgets-browser-browser-pro.html
http://qt-project.org/doc/qt-5.0/qtwebkitexamples/qtwebkitexamples-index.html
And you may want to consider also adding the network module in the pro file, too.
Ok so iv seen the QT +=webkit solution all over the place which for the record doesnt work if you have just dragged a dropped a webview into a widget using qt designer.
the solution i finally found that worked was
QT+=webkitwidgets
all working now thought id answer my own question after solving it to help anyone else who might be having the same problem

How to render html in C++ app using already installed firefox or chrome

We have a requirement to render a local html file in a webview on a mfc window. Currently we have achieved this with IE and now we need to do the same with firefox and then with chrome.
Some of the options suggest using webkit or gecko sdk but we would rather like to use already installed libraries and binaries of these browsers on a windows machine.
It would be of great help if you could point me into some documentation or some sample code to achieve this.
Thanks for your response.
-Aditya
IE provides a COM component but AFAIK none of the other browsers do.
Qt provide QtWebView class, it's a wrapper of WebKit's web view, and it's cross-platform.
Or use MFC/WTL's CHtmlView, but IE so sucks.