PDA

View Full Version : Increase the quality of the image when you Grab() a widget



Saelyth
7th September 2017, 16:53
I'm working with pyqt but it shouldn't make a difference here.

My issue is that I have a widget with some buttons, labels and some icons and generic images on it. I want to save that widget as a screenshot (not the entire window, as there is other widgets around), so I tried with mywidget.grab(), however the quality of the result is quite bad (specially the text at the labels)


sshot = self.widgetReport.grab()
sshot.save("test\file.png")

So my questions are:
- Is there any parameter for the grab method to adjust the quality of the image? (something like grab(quality=high))
- If the above is not possible, is there any way to Scale the content of everything in the widget before screenshoting it and then re-scale back to what it was? (I tried with mywidget.resize() but it only scaled the boundaries, not the content.
- Is there any other way to achieve my goal and get a screenshot of a widget with increased quality (for zooming purposes)?

Thanks in advance.

d_stranz
7th September 2017, 18:35
- Is there any other way to achieve my goal and get a screenshot of a widget with increased quality (for zooming purposes)?

You could use the QWidget::render() to draw into a pixmap of the size you want. I do not know if the "quality" (by which I assume you mean resolution) will be set according to the size of the pixmap, but it is worth trying. Obviously, if your widgets contain pixmap images (like icons), these will remain at whatever resolution they have on screen so you will get blockiness.

The QWidget::grab() method works at screen resolution, as you have observed.