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. #1
    Join Date
    Feb 2015
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

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

    Hi there,

    Using Qt 5.8 QPainter graphics (only text, lines and ellipses) are drawn and saved to QImage (PNG) and QSvgGenerator (SVG) files.
    The graphic is dynamic in size. Because of that the graphic is drawn in an QImage or SVG with maximum size.
    But the QImage / SVG should fit exactly to the size of the graphic. How can this be done?

    1. My thoughts were, there might be a Qt method that can detect the size of the bounding rectangle of the QPainter graphic in the QImage. So the graphic can be drawn again in an QImage with the size of the detected rectangle. So graphic and image fit exactly.

    2. Or there might be a Qt function that is able to cut an QImage to the size of its graphic content automatically. Is there such?

    But maybe I think more complicated as it is. What is the best solution for this problem?
    Last edited by mireiner; 28th February 2017 at 17:34.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.