Opacity with custom QGraphicsItem

  • Hello.

    I wrote a custom graphics item that paints an image with the following code:

    void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
    painter->drawImage(QRectF(QPointF(0,0), m_size), m_image,

    That work very well, but when the item's opacity is less then 1 the colors in the image do not fade to the background color, but to the respective inverse color: It seems that instead of
    (1 - opaticy) * backgroundColor + opacity * color

    the new color is
    (1 - opaticy) * (backgroundColor - color) + opacity * color

    For other items such as QGraphicsTextItem the opacity works as expected. Can somebody point me to what the problem might be?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.