Namespaces

Variants
Actions

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:Colorize 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 on QWidget) is deprecated.

Article Metadata
Code ExampleCompatibility
Platform(s): any
Symbian
Article
Keywords: QGraphicsColorizeEffect
Created: gnuton (23 Dec 2010)
Last edited: hamishwillee (11 Oct 2012)

Introduction

This article shows how to use the colorize effect using Qt's QGraphicsColorizeEffect. Qt Graphics view framework offers a convenient way to apply graphics effects to Graphics Items.

Qt-GraphicsEffect-Colorize.jpg

Code

This is a minimal application which colors a QGraphicsPixmap using the QGraphicsColorizeEffect. The QGraphicsColorizeEffect class provides a colorize effect. The color can be modified using the setColor() function. setStrength() changes the colorize strength property.


#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"));
 
QGraphicsColorizeEffect colorize;
colorize.setColor(QColor(Qt::red)); //Default value is blue
colorize.setStrength(0.5); //Default value is 1.0
p->setGraphicsEffect(&colorize);
 
view.show();
return a.exec();
}

Source code

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

×