Headless QML Screen Capture?

465 views
Skip to first unread message

Steve Scheidecker

unread,
Sep 25, 2013, 9:21:48 AM9/25/13
to phan...@googlegroups.com
Does PhantomJS have the ability to render QML files and capture screen-shots from the rendered QML?  What I'm looking for is the ability to run a QML application within PhantomJS on a headless server and render screen-shot images for users that can be displayed.  In this manner users can preview the output from a QML application without installing QT onto a system.  Since PhantomJS is based on QT I'm assuming that this is possible, but don't see anything in the documentation that indicates either way.

James Greene

unread,
Sep 25, 2013, 9:55:34 AM9/25/13
to phan...@googlegroups.com

Can your QML application normally be loaded in a QWebPage instance via some manner of URI? If not, then the answer would be "no".

Sincerely,
   James Greene
   Sent from my [smart?]phone

On Sep 25, 2013 8:21 AM, "Steve Scheidecker" <st...@info2gousa.com> wrote:
Does PhantomJS have the ability to render QML files and capture screen-shots from the rendered QML?  What I'm looking for is the ability to run a QML application within PhantomJS on a headless server and render screen-shot images for users that can be displayed.  In this manner users can preview the output from a QML application without installing QT onto a system.  Since PhantomJS is based on QT I'm assuming that this is possible, but don't see anything in the documentation that indicates either way.

--
You received this message because you are subscribed to the Google Groups "phantomjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phantomjs+...@googlegroups.com.
Visit this group at http://groups.google.com/group/phantomjs.
For more options, visit https://groups.google.com/groups/opt_out.

James Greene

unread,
Sep 25, 2013, 10:29:27 AM9/25/13
to phan...@googlegroups.com
If you tweaked some of the WebPage.cpp code, you could maybe do it by using/creating a plugin as discussed here:  http://qt-project.org/forums/viewthread/29761

Sincerely,
    James Greene

Ariya Hidayat

unread,
Sep 25, 2013, 10:32:09 AM9/25/13
to phan...@googlegroups.com
> Does PhantomJS have the ability to render QML files and capture screen-shots
> from the rendered QML?

Negative. QML is a completely different technology.



--
Ariya Hidayat, http://ariya.ofilabs.com
http://twitter.com/ariyahidayat
http://gplus.to/ariyahidayat

Steve Scheidecker

unread,
Sep 25, 2013, 10:40:45 AM9/25/13
to phan...@googlegroups.com
No, QML cannot be rendered in QWebPage.  It is rendered in QDeclarativeEngine.  Looking at the phantomjs source I see that QtDeclarative is not included, so that answers my question. 

Does anyone have any idea how difficult it would be to clone the current phantomjs webpage module to replicate its functionality for QtDeclarative?  Has anyone tried this?  I want the same exact head-less screen capture functionality, instead of rendering a webpage I want to render QML. 

With QT 5.2+ offering broader device support this type of rendering capability would be impressive for mobile/embedded developers in allowing headless previews of applications.  It doesn't seem like it would be a significant extension from what phantomjs is already accomplishing.

Steve Scheidecker

unread,
Sep 25, 2013, 10:53:58 AM9/25/13
to phan...@googlegroups.com
Thanks for the link James.  If I were to compile QtDeclarative, how would I go about using QWebPluginFactory in phantomjs?

In this manner I would simply embed the QML into a webpage and do screen capture as normal.  Seems pretty straightforward if I can use QWebPluginFactory from phantomjs and if QtDeclarative works with Lighthouse QPA

Ariya Hidayat

unread,
Sep 25, 2013, 11:12:10 AM9/25/13
to phan...@googlegroups.com
I am still puzzled as to why a headless rendering of QML requires a
long detour via WebKit. Consult Digia or their related partners to
search for a proper solution.

PhantomJS is not meant for general headless solution for Qt. We will
stick with only web standards via (Qt)WebKit. In the past (search the
archive), support for NPAPI plugin was even removed.

James Greene

unread,
Sep 25, 2013, 11:24:21 AM9/25/13
to phan...@googlegroups.com
Definitely agree with Ariya on this point.  It seems like you could achieve this by using QPixmap to take an application screenshot instead, e.g.:

Then all you'd have to do is make your application headless, so either faking it with xvfb or else utilizing QPA/Lighthouse properly like Phantom does.

Sincerely,
    James Greene



Reply all
Reply to author
Forward
0 new messages