Results 1 to 3 of 3

Thread: Opacity with Qt

  1. #1
    Join Date
    May 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Opacity with Qt

    Hello.

    I would like to change the opacity of a shape in a QgraphicsView by increasing the value in a variable white a horizontal slider but I can not do it. I tried with this code but it does not matter.

    Qt Code:
    1. qreal opacity = 0.0;
    2. shape->setOpacity(opacity);
    To copy to clipboard, switch view to plain text mode 

    Thank you.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Opacity with Qt

    You probably need to call QGraphicsView::invalidateScene() or QGraphicsView::update() after making the change. If your items are children of other items, you may also have to set opacity propagation flags ( see QGraphicsItem::setOpacity()):

    There are two item flags that affect how the item's opacity is combined with the parent: ItemIgnoresParentOpacity and ItemDoesntPropagateOpacityToChildren.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    May 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Opacity with Qt

    Hello thank you very much but it does not help me much better with a small piece of code I will continue to search...

Similar Threads

  1. Set opacity in Linux
    By Momergil in forum Qt Programming
    Replies: 6
    Last Post: 18th June 2014, 15:02
  2. QMainWindow Opacity
    By Henry Blue Heeler in forum Newbie
    Replies: 3
    Last Post: 11th January 2014, 22:25
  3. change the opacity
    By askatuak in forum Qt Quick
    Replies: 1
    Last Post: 18th September 2013, 17:20
  4. Window Opacity
    By chethana in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2007, 11:45
  5. Opacity in Linux OS
    By shyam prasad in forum Qt Programming
    Replies: 2
    Last Post: 22nd May 2007, 06:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.