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 print a part of an Item?
Forum Updated to NodeBB v4.3 + New Features

How to print a part of an Item?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 4 Posters 460 Views 2 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.
  • C Offline
    C Offline
    cq_qt
    wrote on last edited by cq_qt
    #1

    An Item has a huge size. Let's say 500000X500000. And the Item has thousands of childItems.
    Then I want to print a part of this Item(including its children), the letftop is a point in this Item,the width and height are 3000 pixels.
    I found the method of QQuickItem::grabToImage that can grab the whole Item.But I don‘t find a method can grab a part of an Item.
    Is there a method that can grab a part of Item into Image?

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      You realize that without compression that would be a 1 Terabyte image?
      What can possibly take 500K x 500K pixels to produce?

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cq_qt
        wrote on last edited by
        #3

        you are right. I changed my question.

        1 Reply Last reply
        0
        • fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          I would look into using a shader effect from qml to render a portion of the larger item to a smaller item. Then use grabToImage on that smaller item. I know there are ways to cut pieces using the shader effects. I just cannot remember which one to use.

          C++ is a perfectly valid school of magic.

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            You can specify the target size in functions parameter: https://doc.qt.io/qt-5/qquickitem.html#grabToImage-1. The QML version also has target size https://doc.qt.io/qt-6/qml-qtquick-item.html#grabToImage-method

            (Z(:^

            1 Reply Last reply
            0
            • GrecKoG Offline
              GrecKoG Offline
              GrecKo
              Qt Champions 2018
              wrote on last edited by GrecKo
              #6

              That's the target size, not the source rect which OP seems to want. As mentionned by fcarney you could get a part of the item by calling grabToImage on a ShaderEffectSource with sourceItem and sourceRect set accordingly.

              1 Reply Last reply
              2
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                You can also call grabToImage on an Item that you manually set to correct size.

                (Z(:^

                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