How to render application offscreen and do "screenshot"
m_rx last edited by
i have a digital signage application that does ui elements via qml.
it features transitions and graphical effects.
it also includes a web server that serves screenshots via a rest interface.
what i'd like to have:
- a single executable for client and service mode
- if run as application: go fullscreen and render ui ...
- if run as service: don't show a window/ui. render content (which are ui elements image/webview/video etc - not qpainter-ed graphics) in the background and serve rest-requests
- client mode is working as it should
- in service mode create a qimage/qpixmap in the required pseudo resolution (like 1920x1080)
- render the application to that image as if it were running on a fullhd screen
- do "screenshots" off that image for rest calls
is this feasible?
how would i go about it?
can i render my top-level qquickview to a hidden screenbuffer?
if i simply hide the qquickview, the all drawing is optimized away ...
I need to develop a similar application, I intend to implement it by Qt too. I want to know the answers.
Any helps will be greatly appreciated.
read "How to take ScreenShot Qt/QML":http://www.qtcentre.org/threads/54964-How-to-take-ScreenShot-Qt-QML
and read http://doc-snapshot.qt-project.org/qt5-stable/qtquick/qquickwindow.html#grabWindow
Grabs the contents of the window and returns it as an image.
It is possible to call the grabWindow() function when the window is not visible. This requires that the window is created and has a valid size and that no other QQuickWindow instances are rendering in the same process.
Warning: Calling this function will cause performance problems.
Warning: This function can only be called from the GUI thread.
but someone said grabWindow() can't work with hidden QML window.
read "Capture QML drawing buffer, without displaying":http://stackoverflow.com/questions/17146747/capture-qml-drawing-buffer-without-displaying
I get confused, whether grabWindow() work with hidden window?
m_rx last edited by
if i hide(); or setVisible(false); the window, i can't get a screenshot anymore.
Moving the window past the right screen border works though ...
That's not exactly the cleanest way, but is ok for me.
I found a class called "QOffscreenSurface"
Should we use "QOffscreenSurface"?
Would you mind showing your code to me?
btw, "there also is a plugin named "offscreen", which is intended for testing, but is not currently being developed."
read "this thread":http://lists.qt-project.org/pipermail/development/2013-November/014030.html