Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 01:13, 11 October 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Blur effect with the Qt Graphics View Framework

From 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:

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