Hi guys,

I posted this on 
stackoverflow(http://stackoverflow.com/questions/33217930/qtwebengine-printing-a-webpage-invoked-by-javascript
 
<http://stackoverflow.com/questions/33217930/qtwebengine-printing-a-webpage-invoked-by-javascript>),
 but then it occurred to me that I probably should have posted it here first.

I’m porting a project from Qt4.8.6 to Qt5.5.1.  In doing so, we are hoping to 
upgrade from QtWebkit to QtWebEngine.  I am slowly going through the list of 
things that need to be done to allow that port to happen.  My current subject 
of interest is printing.

Looking here (https://trello.com/c/JE5kosmC/72-printing-support 
<https://trello.com/c/JE5kosmC/72-printing-support>) it seems like official 
printing support for QtWebEngine won’t come until Qt5.7.  Luckily it appears 
like there are options until then.

From here (http://stackoverflow.com/questions/32711901/qwebengine-print-a-page 
<http://stackoverflow.com/questions/32711901/qwebengine-print-a-page>), I know 
that I can use QWebEngineView::render, passing in a pointer to my QPrinter 
object to programmatically print a web page.

But if the print request was invoked by javascript (from the window.print() 
javascript function for instance), I don't know how to catch that request to 
then hand off to my print function.

I found this 
(http://tjvantoll.com/2012/06/15/detecting-print-requests-with-javascript/ 
<http://tjvantoll.com/2012/06/15/detecting-print-requests-with-javascript/>) 
which apparently allows you to call another javascript function when the print 
function is invoked.  Perhaps I can somehow inject this javascript into the 
page and use it somehow with QWebChannel (a completely new class to me) to 
catch the javascript print command and relay it to my c++ print function?

Or perhaps I’m completely barking up the wrong tree.

Does anyone have any thoughts?

--
Jason Dolan
Software Developer
PCC
Control Your Future.

800-722-7708
[email protected] <mailto:[email protected]>
www.pcc.com <http://www.pcc.com/>
twitter.com/pccvt



_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to