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
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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: