Results 1 to 2 of 2

Thread: Increase the quality of the image when you Grab() a widget

  1. #1
    Join Date
    Aug 2017
    Posts
    11
    Qt products
    Qt5
    Platforms
    Windows

    Default Increase the quality of the image when you Grab() a widget

    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)

    Qt Code:
    1. sshot = self.widgetReport.grab()
    2. sshot.save("test\file.png")
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by Saelyth; 7th September 2017 at 17:13. Reason: Better this way

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Increase the quality of the image when you Grab() a widget

    - 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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Help with QWidget::grab
    By mikea in forum Newbie
    Replies: 6
    Last Post: 19th September 2014, 10:58
  2. Replies: 7
    Last Post: 31st May 2011, 00:10
  3. How to grab screen on thread?
    By Alex Snet in forum Qt Programming
    Replies: 6
    Last Post: 18th May 2009, 22:08
  4. grab images from Phonon video
    By Kraut~salat in forum Qt Programming
    Replies: 3
    Last Post: 19th January 2009, 10:53
  5. Grab idea from Amarok
    By jiveaxe in forum Qt Programming
    Replies: 8
    Last Post: 6th November 2007, 19:11

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.