Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to render application offscreen and do "screenshot"

How to render application offscreen and do "screenshot"

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 2 Posters 8.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m_rx
    wrote on last edited by
    #1

    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

    idea:

    • 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 ...

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vincent007
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vincent007
        wrote on last edited by
        #3

        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

        QImage QQuickWindow::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.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          Vincent007
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            m_rx
            wrote on last edited by
            #5

            Update:

            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.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              Vincent007
              wrote on last edited by
              #6

              I found a class called "QOffscreenSurface"

              Should we use "QOffscreenSurface"?

              1 Reply Last reply
              0
              • V Offline
                V Offline
                Vincent007
                wrote on last edited by
                #7

                Hi m_rx

                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

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved