[Interest] QWidget render to different size

Israel Brewster ijbrewster at alaska.edu
Thu Aug 15 01:23:14 CEST 2019

When calling QWidget->render() (or the like), is there a way to get it to render at a different size? I have a widget that I am trying to capture to a png file, but I let the user decide what dimensions they want it to be saved at. I can easily make a QPixmap of desired size, but when I call render() on my widget, it just renders into a portion of the pixmap (if the pixmap is larger than the widget) or cuts off a portion (if the pixmap is smaller). Scaling the pixmap after rendering isn’t a good option, since aside from the loss of quality, it would scale *everything* in the pixmap, whereas changing the size of the QWidget actually results in some items moving and other scaling (much more complex than just make everything twice as big. Fonts, for example, should remain the same size).

I can resize the widget (by calling setFixedSize()) prior to calling render, which works, but that results in a visual glitch. Is there some better way to render the widget at a specific size? 
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190814/d4d49f9b/attachment.html>

More information about the Interest mailing list