Hi, I need your precious help for drawing shadows in QAbstractItemDelegate::paint() event. This is a summary: my application has a QListView and a QListWidget. I used two different widgets since the former have to contains hundreds of item, each with few controls, while the latter few items, each with more controls (self-hiding buttons, labels, etc) but when in rest state they look very similar. Each item in two lists show a pixmap that I draw in paint() event for the QListView while using a simple QLabel for the QListWidget. Now I added a shadow around the QLabel in QListWidget's item with the following code:

Qt Code:
  1. QGraphicsDropShadowEffect *coverShadow = new QGraphicsDropShadowEffect(this);
  2. coverShadow->setBlurRadius(10.0);
  3. coverShadow->setColor(QPalette::Shadow);
  4. coverShadow->setOffset(0.0);
  5. label->setGraphicsEffect(coverShadow);
To copy to clipboard, switch view to plain text mode 

It works fine.

Now I would apply something similar to the pixmap in QListView's items. I tryed using QLinerGradient and QRadialGradient but the result is not satisfactory. The shadow is different from that in QListWidget.

In docs i found that setGraphicsEffect() (used in the code above) is a method of QWidget and QGraphicsItem. I tryed with a QGraphicsPixmapItem this way:

Qt Code:
  1. QGraphicsPixmapItem gpItem(mPixmap);
  2. gpItem.setTransformationMode(Qt::SmoothTransformation);
  3. QGraphicsDropShadowEffect *coverShadow = new QGraphicsDropShadowEffect;
  4. coverShadow->setBlurRadius(10.0);
  5. coverShadow->setColor(QPalette::Shadow);
  6. coverShadow->setOffset(0.0);
  7. gpItem.setGraphicsEffect(coverShadow);
  8. painter->drawPixmap(shadowRect, gpItem.pixmap());
To copy to clipboard, switch view to plain text mode 

The idea was to load the pixmap, apply the effect and return the final result, but probably it doesn't work this way since I obtain an up-scaled portion of the original pix (never used QGraphicsItem).

Have you any idea how to solve this?

Regards