×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Shadow effect with the Qt Graphics View Framework

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
hamishwillee (Talk | contribs)
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
Line 29: Line 29:
 
This is a minimal application which creates a shadow for a [http://doc.qt.nokia.com/4.7/qgraphicspixmapitem.html QGraphicsPixmap] using the {{Icode|QGraphicsShadowEffect}}.
 
This is a minimal application which creates a shadow for a [http://doc.qt.nokia.com/4.7/qgraphicspixmapitem.html QGraphicsPixmap] using the {{Icode|QGraphicsShadowEffect}}.
  
<code cpp>
+
<code cpp-qt>
 
#include <QtGui/QApplication>
 
#include <QtGui/QApplication>
 
#include <QGraphicsView>
 
#include <QGraphicsView>

Latest revision as of 04:15, 11 October 2012

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
Compatibility
Platform(s): any
Symbian
Article
Keywords: QGraphicsShadowEffect
Created: gnuton (24 Dec 2010)
Last edited: hamishwillee (11 Oct 2012)

[edit] Code

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;
shadow.setBlurRadius(100.0);
shadow.setColor(Qt::red);
shadow.setOffset(0,0);
p->setGraphicsEffect(&shadow);
 
view.show();
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.

[edit] Source code

You can download the code from here: Media:GraphicsEffect-shadow.zip‎

This page was last modified on 11 October 2012, at 04:15.
100 page views in the last 30 days.
×