Http://qt-project.org/wiki/Category:HowTo
Class Highlighteffect:public qgraphicseffect
{
q_object
q_property (qcolor color READ Color WRITE setcolor)
q_property (qpointf offset READ offset WRITE setoffset) public
:
Highlighteffect (qreal offset = 1.5);
Virtual QRECTF boundingrectfor (const QRECTF &sourceRect;) const;
Qcolor Color () const {return Mcolor}
void SetColor (Qcolor &color;) {mcolor = color;}
qpointf offset () const {return moffset}
void setoffset (qpointf offset) {moffset = offset;}
Protected:
virtual void Draw (Qpainter *painter);//, Qgraphicseffectsource *source);
Private:
qcolor mcolor;
qpointf moffset;
};
Highlighteffect::highlighteffect (qreal offset): Qgraphicseffect (), Mcolor (255, 255, 0, 128),//Yellow, Semi-tra
Nsparent moffset (offset, offset) {} QRECTF highlighteffect::boundingrectfor (const QRECTF &sourceRect;) const
{return sourcerect.adjusted (-moffset.x (),-moffset.y (), Moffset.x (), Moffset.y ());}
void Highlighteffect::d raw (Qpainter *painter) {qpoint offset;
Qpixmap Pixmap; if (Sourceispixmap ())//doesn ' t seems to work, return false {//No point in drawing in device coordinates (PIXMA
P'll be scaled anyways). Pixmap = Sourcepixmap (qt::logicalcoordinates, &offset;);
, mode);
} QRECTF bound = Boundingrectfor (Pixmap.rect ());
Painter->save ();
Painter->setpen (Qt::nopen);
Painter->setbrush (Mcolor);
qpointf P (offset.x ()-moffset.x (), Offset.y ()-moffset.y ());
Bound.movetopleft (P);
Painter->drawroundedrect (Bound, 5, 5, qt::relativesize);
Painter->drawpixmap (offset, pixmap); Painter-&gT;restore (); }
Pixmap *item = new Pixmap (KINETICPIX);
Highlighteffect *effect = new Highlighteffect ();
Item->setgraphicseffect (effect);
It is a good high light effect to make a record for the time being.