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 over the next few weeks. Thanks for all your past and future contributions.

Archived:Shadow 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 (C++ for the Qt UI) is deprecated.

This article shows how to use QGraphicsShadowEffect to apply a shadow effect to Graphics Items. none‎

Article Metadata
Platform(s): any
Keywords: QGraphicsShadowEffect
Created: gnuton (24 Dec 2010)
Last edited: hamishwillee (11 Oct 2012)


This is a minimal application which creates a shadow for a QGraphicsPixmap using the QGraphicsShadowEffect.

#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"));
QGraphicsDropShadowEffect shadow;
return a.exec();

The QGraphicsDropShadowEffect class provides a drop shadow effect. A drop shadow effect renders the source with a drop shadow. The color of the drop shadow can be modified using the setColor() function. The drop shadow offset can be modified using the setOffset() function and the blur radius of the drop shadow can be changed with the setBlurRadius() function.

Source code

You can download the code from here:‎

This page was last modified on 11 October 2012, at 01:15.
119 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.