A sample highlighting QGraphicsEffect

From Qt Wiki
Revision as of 13:56, 14 January 2015 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

English | فارسی

While learning Qt, I wrote this sample highlighting graphics effect to be used with rectangular QGraphicsPixmapItem.
..and I use this post just to learn how to publish a wiki page here too.. ;-)

highlight.h

highlight.cpp

The strange thing in the implementation is that the sourceIsPixmap() function returns always false, even if the documentation states that “Returns true if the source effectively is a pixmap, e.g., a QGraphicsPixmapItem.”
I ask to Qt gurus what can be going on here…

The default color is pale yellow, semi-transparent and the border size is set to 1.5. To add the effect simply add this:

Here the modified animated tiles example with the effect turned on:

Animated tiles example with QGraphicsPixmapItem highlighting

Hope someone found this useful.

Categories: