[Development] QWebEngineView Print

Sudhir Sharma Sudhir.Sharma at mindtree.com
Mon Jul 17 06:33:19 CEST 2017


Kevin,

Thanks very much for your response. Just upgrading QtWebEngine to 5.8 or 5.9 will suffice my requirement.
Exploring how can I do that as I have not built QT but using QT installer in Visual Studio 2013.

Do you have any idea if it can be done in my scenario?

Regards,
Sudhir

-----Original Message-----
From: Development [mailto:development-bounces+sudhir.sharma=mindtree.com at qt-project.org] On Behalf Of Kevin Kofler
Sent: Friday, July 14, 2017 4:21 PM
To: development at qt-project.org
Subject: Re: [Development] QWebEngineView Print

* You are receiving this mail from an external source *

Sudhir Sharma wrote:
> How can we print html loaded in QWebEngineView in QT 5.7?

In 5.7, you can only print by first printing to PDF and then invoking something external to actually send the PDF to a printer. See the code (submitted by me) in QupZilla 2.1.x (and currently also in master/2.2, but since that requires Qt 5.8, it may be ported to the direct print method soon, I've been wanting to look into that for a while). But that code assumes the lpr executable is available on *nix, and there is an implementation for Windows that is rather suboptimal (invokes the configured PDF viewer and asks it to print).

You may want to upgrade to 5.8 or 5.9, where you just have to invoke the print method.

It is also possible to upgrade QtWebEngine to 5.8 or 5.9 while keeping Qt 5.7, you will just need this one-line fix:

http://pkgs.fedoraproject.org/cgit/rpms/qt5-qtwebengine.git/plain/qtwebengine-opensource-src-5.8.0-qt57.patch

and you may want to explicitly enable spellchecking, which is disabled by default when building against Qt 5.7:

WEBENGINE_CONFIG+=use_spellchecker

and if you are using CMake, you will likely also need this tweak on the installed QtWebEngineConfig*.cmake files:

sed -i -e "s|%{version} \${_Qt5WebEngine|%{_qt5_version} \${_Qt5WebEngine|" \
  %{buildroot}%{_qt5_libdir}/cmake/Qt5WebEngine*/Qt5WebEngine*Config.cmake

QtWebEngine is the only part that of Qt you need to upgrade to get the print method.

        Kevin Kofler

_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

________________________________

http://www.mindtree.com/email/disclaimer.html



More information about the Development mailing list