Results 1 to 8 of 8

Thread: Screenshot only for the rect of certain items on the scene

  1. #1
    Join Date
    Apr 2009
    Posts
    12
    Thanks
    2
    Qt products
    Qt4

    Default Screenshot only for the rect of certain items on the scene

    Hi,

    I am trying to make a screenshot/Pixmap out of certain graphicItems on a QGraphicsScene object like this:

    Qt Code:
    1.  
    2. foreach(QPointer<ListOfItems> item, itemsToPrint.list())
    3. {
    4. itemGroup->addToGroup(item);
    5. }
    6.  
    7. QRectF selectionRect = itemGroup->boundingRect();
    8. QPixmap image(selectionRect.width(), selectionRect.height());
    To copy to clipboard, switch view to plain text mode 

    Then render the image and I hoped that it will render/print in the screenshot only the items I need to. But instead of that, the screnshot that is created is fuzzy (nothing visible is shown properly), and the items from the main scene disappear

    How can I make screenshot of part of the scene over the boundingRect of items that match some criteria? any example on this?

    thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Screenshot only for the rect of certain items on the scene

    Now you are creating an empty pixmap (with undetermined contents) that is the size of the selection. You probably want to use QGraphicsScene::render()
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2009
    Posts
    12
    Thanks
    2
    Qt products
    Qt4

    Default Re: Screenshot only for the rect of certain items on the scene

    ok, but why the topics do disappear when I add them to qgraphicsgroupitem object? :S

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Screenshot only for the rect of certain items on the scene

    Because the group is not part of the scene. I'm not sure why you're adding that group in the first place.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2009
    Posts
    12
    Thanks
    2
    Qt products
    Qt4

    Default Re: Screenshot only for the rect of certain items on the scene

    Well... how can I get the boundingRect only for the items on the scene that match my criteria? :/ I don't need a boundingRect for all of the items on the scene, just for some of them..

    Even if I create new QGraphicsScene object and then add these items via QGraphicsScene::addItem(..) the topics disappear :s.

    isn't there any example on this matter? thanks wysota.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Screenshot only for the rect of certain items on the scene

    Quote Originally Posted by afail View Post
    Well... how can I get the boundingRect only for the items on the scene that match my criteria?
    Unite the rects of all interesting items.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Apr 2009
    Posts
    12
    Thanks
    2
    Qt products
    Qt4

    Default Re: Screenshot only for the rect of certain items on the scene

    Ok I hope this is my last reply since I am not getting the needed results, but I am close to it.

    Qt Code:
    1. QRectF shotRect = item.current().boundingRect();
    2. foreach(ItemType item, itemsList)
    3. {
    4. shotRect = shotRect.united(item->boundingRect());
    5. }
    To copy to clipboard, switch view to plain text mode 

    now, as I read in the doc, shotRect should unite all of the rects that are in the itemsList list object. But it always has the value of the rect of biggest item on the scene. which is not what I need. what am I not doing right?

    thanks sorry (graphics seem a little heavy for me )

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Screenshot only for the rect of certain items on the scene

    The code seems correct. Please provide a minimal compilable example reproducing the problem - then we can work on it to find the problem on your side.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 6
    Last Post: 8th June 2009, 22:44
  2. add items into scene
    By Noxxik in forum Qt Programming
    Replies: 0
    Last Post: 9th March 2009, 17:32
  3. How to set definite Scene Rect in QGraphicsView.
    By AmolShinde_8 in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2008, 16:18
  4. Can't move Items in the scene
    By maverick_pol in forum Qt Programming
    Replies: 2
    Last Post: 16th May 2008, 10:40
  5. How to update scene after removing items
    By nileshsince1980 in forum Qt Programming
    Replies: 4
    Last Post: 20th September 2007, 10:56

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.