Example QLinearGradient to create a 3-D shadow effect

Qt Graphics View Lesson 2

Example using QLinearGradient (QGradient) to create a 3-D shadow effect

Download the complete project zip file

screen shot of demo app

In this example, I wanted to creat a 3-D shadow effect around my simple box. I used the QGradient class to create the background shadow, then drew another rounded-rect over that, offset by 3 pixels.

The class StateBox is the widget that represents the box in the scene. Its derived from the QGraphicsItem. MainWindow.cpp creates the scene and inserts a StateBox object.

Leave a Reply

Trackback this post  |  Subscribe to the comments via RSS Feed