Results 1 to 4 of 4

Thread: Problem applying QGraphicsBlurEffect to a QGraphicsPixmapItem

  1. #1
    ucomesdag Guest

    Default Problem applying QGraphicsBlurEffect to a QGraphicsPixmapItem

    Hi all,

    I try to apply blur to an image but nothing seems to happen and can't wrap my head arround whatmight be wrong here:

    Qt Code:
    1. QPixmap buffer(image.size());
    2. QGraphicsPixmapItem item(buffer);
    3. QGraphicsBlurEffect effect;
    4. effect.setBlurHints(QGraphicsBlurEffect::QualityHint);
    5. effect.setBlurRadius(5);
    6. item.setGraphicsEffect(&effect);
    7.  
    8. item.pixmap().toImage().save("blur.png");
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Problem applying QGraphicsBlurEffect to a QGraphicsPixmapItem

    Ehm, you are constructing an empty pixmap, and blur an empty pixmap results in an empty pixmap You might want to try
    Qt Code:
    1. QPixmap buffer(image);
    To copy to clipboard, switch view to plain text mode 

    And also I think that the pixmap function of the item returns the unmodified source pixmap of the item. But I am not sure on that. So if you want save it you have to render the scene or set the pixmap to a label and render that back to a pixmap.

  3. #3
    ucomesdag Guest

    Default Re: Problem applying QGraphicsBlurEffect to a QGraphicsPixmapItem

    Nope it ain't an empty pixmap. But you hit a point, how could I render it as it's offscreen?

  4. #4
    Join Date
    Jul 2010
    Posts
    21
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem applying QGraphicsBlurEffect to a QGraphicsPixmapItem

    You will probably have to add your item to a QGraphicsScene, which you can then render() off-screen using your own QPainter. See also QGraphicsView::render() for off-screen rendering and some examples related to printing.

  5. The following user says thank you to hobbyist for this useful post:


Similar Threads

  1. Applying QSqlTableModel to QTableView
    By SykeS in forum Newbie
    Replies: 1
    Last Post: 20th May 2010, 09:34
  2. Applying a consistent background
    By KanadaKid in forum Qt Programming
    Replies: 2
    Last Post: 27th December 2009, 17:56
  3. Problem applying setWindowOpacity to a custom Widget
    By yellowmat in forum Qt Programming
    Replies: 8
    Last Post: 1st November 2006, 10:05
  4. Applying fonts to QListWidgetItems
    By L.Marvell in forum Qt Programming
    Replies: 4
    Last Post: 8th May 2006, 10:04

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.