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. QML Quick Scene in to PDF via ScreenShot - Poor Resolution
Forum Update on Monday, May 27th 2025

QML Quick Scene in to PDF via ScreenShot - Poor Resolution

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 3 Posters 2.2k Views
  • 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.
  • michaelLM Offline
    michaelLM Offline
    michaelL
    wrote on last edited by
    #1

    Hi,

    as faar as i know, i cant draw anything from QML to a file or PDF.
    So the only way is to make a screen shot from the window: https://forum.qt.io/topic/28262/solved-how-to-take-screenshot-qt-qml/2

    Now that i have my QImage and i made my PDF with 300DPI the ScreenShot image doesnt look so nice. My display has a resolution of 1280x800 so the screen shot QImage will have that.
    How can i boost up my QImage so it looks good at 300DPI?

    raven-worxR 1 Reply Last reply
    0
    • michaelLM michaelL

      Hi,

      as faar as i know, i cant draw anything from QML to a file or PDF.
      So the only way is to make a screen shot from the window: https://forum.qt.io/topic/28262/solved-how-to-take-screenshot-qt-qml/2

      Now that i have my QImage and i made my PDF with 300DPI the ScreenShot image doesnt look so nice. My display has a resolution of 1280x800 so the screen shot QImage will have that.
      How can i boost up my QImage so it looks good at 300DPI?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @michaelL
      what about grabToImage() with a high target size?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • michaelLM Offline
        michaelLM Offline
        michaelL
        wrote on last edited by
        #3

        @raven-worx said in QML Quick Scene in to PDF via ScreenShot - Poor Resolution:

        high target size

        You mean that i could make my target very big and use the grabToImage() function to make it into a picture?

        raven-worxR 1 Reply Last reply
        0
        • michaelLM michaelL

          @raven-worx said in QML Quick Scene in to PDF via ScreenShot - Poor Resolution:

          high target size

          You mean that i could make my target very big and use the grabToImage() function to make it into a picture?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @michaelL
          i don't know for sure, but simply give it a try:

          item.grabToImage(function(result) {
                                     // do something with "result.url"
                                     result.saveToFile("something.png");
                                 },
                                 Qt.size(1280*3, 800*3)); // just some dummy values here
          

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1
          • timdayT Offline
            timdayT Offline
            timday
            wrote on last edited by timday
            #5

            QML-to-PDF capture actually used to be easier in the SW-rendered (QPainter-based) original QtQuick1/QtDeclarative. Some related comments on this, and attempts to work round it, at:

            • https://stackoverflow.com/questions/20825233/how-to-print-a-qquickviews-contents-to-pdf
            • http://blog.qt.io/blog/2016/08/15/the-qt-quick-graphics-stack-in-qt-5-8/ (see the comments on that and https://bugreports.qt.io/browse/QTBUG-55321 )
            • https://www.kdab.com/creating-pdf-qtquick-2-scene-slideviewer/

            Quite interested to hear what that size argument to grabToImage does. My guess would have been that providing a larger size than the Item it just gets you a fuzzy image of it... but I'd be pleasantly surprised and impressed if it actually re-renders the item and all it's child items at higher resolution.

            1 Reply Last reply
            0
            • michaelLM Offline
              michaelLM Offline
              michaelL
              wrote on last edited by
              #6

              @raven-worx It works!
              So i grab my rectangle into an Image and did Qt.size(10003, 6203).
              My rectangle has 1000x620 pixel size.
              I open the image and it has 3000x1860 pixels. Awesome!

              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