Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Opacity with custom QGraphicsItem

Opacity with custom QGraphicsItem

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mkuettler
    wrote on last edited by
    #1

    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)
    {
    Q_UNUSED(option);
    Q_UNUSED(widget);
    painter->drawImage(QRectF(QPointF(0,0), m_size), m_image,
    m_image.rect());
    }
    @

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved