Archived:Blur effect with the Qt Graphics View Framework

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based UIs created using C++) is deprecated.

Article Metadata
Code ExampleCompatibility
Platform(s): all Qt
Keywords: QGraphicsBlurEffect, QGraphicsPixmapItem
Created: gnuton (23 Dec 2010)
Last edited: hamishwillee (11 Oct 2012)


This code example shows how to use the blur effect in image using the Qt Graphics View Framework. The framework offers a convenient way to apply graphics effect to Graphics Items.



This is a minimal application which blurs a QGraphicsPixmapis using the QGraphicsBlurEffect. A blur effect blurs the source. This effect is useful for reducing details, such as when the source loses focus and you want to draw attention to other elements.

#include <QtGui/QApplication>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QGraphicsEffect>
int main(int argc, char *argv[])
QApplication a(argc, argv);
QGraphicsView view;
view.setScene(new QGraphicsScene);
QGraphicsPixmapItem *p = view.scene()->addPixmap(QPixmap(":/meditate.png"));
QGraphicsBlurEffect blur;
blur.setBlurRadius(10); // default value is 5px
return a.exec();

setBlurRadius() holds the blur radius of the effect. Using a smaller radius results in a sharper appearance, whereas a bigger radius results in a more blurred appearance. setBlurHints() holds the blur hint of the effect. The QualityHint is used to prefer a higher quality blur.

Source code

Code is downloadable from here: Media:GraphicsEffect-Blur.zip

This page was last modified on 11 October 2012, at 01:13.
71 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.