Results 1 to 7 of 7

Thread: How to fit a QImage or SVG to the size of its dynamic QPainter graphics content?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Feb 2015
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to fit a QImage or SVG to the size of its dynamic QPainter graphics content?

    Sorry, because of my poor English I probably wasn't clear enough in my first post.

    A QPainter graphic should be drawn into a QImage. And this QImage is saved to a file (not drawn on screen).

    When the QPainter graphic is drawn into the QImage the size of the graphic isn't known before. The graphic size can vary a third of its size. But the graphic resolution should stay always fixed! So scaling the graphic is no option. But the size of the QImage should be sized / resize to the size of the QPainter graphic!

    Now I first create a QImage with the maximal size the QPainter graphic can reach. And then the QPainter graphic is drawn into this QImage. But in this way most of the time the QImage is much larger than its graphic content. Because the graphic always begins in the upper left corner the blank white parts of the QImage are on its right and lower side.

    The question is how to shrink the QImage to the size of its fixed size graphic content? Or how to cut the blank parts of the QImage so the QImage got exact the size of its graphic content?
    Last edited by mireiner; 1st March 2017 at 09:15.

Similar Threads

  1. copy QPainter content to a QImage
    By danics in forum Qt Programming
    Replies: 11
    Last Post: 17th January 2013, 06:38
  2. Dynamic Scrollarea Content
    By rouge in forum Qt Programming
    Replies: 6
    Last Post: 14th May 2011, 08:37
  3. Replies: 1
    Last Post: 24th January 2011, 13:57
  4. Replies: 0
    Last Post: 26th October 2010, 17:59
  5. QPainter(&QPrinter) & QPainter(&QImage) communication
    By gufeatza in forum Qt Programming
    Replies: 2
    Last Post: 2nd February 2010, 07:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.