I think (if not mistaken) now I got your problem...
No you cannot detect the size of the QImage painted by QPainter, it works other way, you are supported to set the size of QImage and QPainter will respect it.
Looks like you need to use QGraphicsView framework to draw the items and then calculated the bonding box and then generate the QImage/SVG from there.
Bookmarks