Results 1 to 3 of 3

Thread: grabwidget image capturing problem

  1. #1
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question grabwidget image capturing problem

    I am trying to capture the image of a QGraphicsView . I have used grabwidget to capture this image . I have written a small program and i successfully captured the image . But the problem is when i tried to integrate it with my product the image captured is not clear (dark lines and spots on the image ). Can anyone give me any siggestion on this.

  2. #2
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: grabwidget image capturing problem

    Hi,

    You can also render your Scene to a pixmap and save it. See for example:

    Qt Code:
    1. QImage *image = new QImage(103,103,QImage::Format_RGB32); //Creates an image of a size 103x103 //Change for the size of your scene
    2. QRgb value;
    3. value = qRgb(255, 255, 255);
    4. image->fill(value); //Fill the image with white
    5. QPainter *painter = new QPainter(image); //Create a new painter based on the image
    6.  
    7. //Renders the scene to the painter
    8. scene.render(painter);
    9.  
    10. image.save("/home/cquiros/tnkicono.jpg","JPG"); //Saves the image
    To copy to clipboard, switch view to plain text mode 

    Depending on the file format, you will lose some image quality.

    Hope it helps.

    Carlos

  3. The following 2 users say thank you to qlands for this useful post:

    Dong Back Kim (11th August 2011), prasannach88 (16th August 2011)

  4. #3
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: grabwidget image capturing problem

    Thanks i tried with render and it worked .

Similar Threads

  1. Replies: 4
    Last Post: 22nd July 2011, 06:40
  2. Replies: 1
    Last Post: 3rd May 2010, 09:25
  3. grabWidget problem
    By gonzoboy! in forum Qt Programming
    Replies: 10
    Last Post: 17th November 2009, 23:10
  4. problem with QPixmap::grabWidget()
    By momesana in forum Qt Programming
    Replies: 6
    Last Post: 19th October 2007, 00:57
  5. grabWidget
    By mickey in forum Qt Programming
    Replies: 12
    Last Post: 17th March 2006, 11:18

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.