Results 1 to 5 of 5

Thread: Multiple GraphicEffects on QLabel

  1. #1
    Join Date
    Jul 2015
    Location
    Austria
    Posts
    20
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Question Multiple GraphicEffects on QLabel

    How can i combine multiple QGraphics*******Effects?
    When i apply more effects on a label only the last one do something.
    Qt Code:
    1. blurEffect=new QGraphicsBlurEffect();
    2. blurEffect->setBlurRadius(5);
    3. blurEffect->setEnabled(true);
    4.  
    5. dropShadowEffect=new QGraphicsDropShadowEffect();
    6. dropShadowEffect->setBlurRadius(5);
    7. dropShadowEffect->setEnabled(true);
    8.  
    9. l->setGraphicsEffect(blurEffect);
    10. l->setGraphicsEffect(dropShadowEffect);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    315
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Multiple GraphicEffects on QLabel

    Did you read the documentation for QGraphicsItem::setGraphicsEffect()?

    void QGraphicsItem::setGraphicsEffect(QGraphicsEffect * effect)
    Sets effect as the item's effect. If there already is an effect installed on this item, QGraphicsItem will delete the existing effect before installing the new effect. You can delete an existing effect by calling setGraphicsEffect(0).

    If effect is the installed effect on a different item, setGraphicsEffect() will remove the effect from the item and install it on this item.
    If you want to combine effects, then you will have to derive your own class from QGraphicsEffect and reimplement the draw() method, as it also says in the docs:

    To create your own custom effect, create a subclass of QGraphicsEffect (or any other existing effects) and reimplement the virtual function draw(). This function is called whenever the effect needs to redraw. The draw() function takes the painter with which to draw as an argument. For more information, refer to the documenation for draw(). In the draw() function you can call sourcePixmap() to get a pixmap of the graphics effect source which you can then process.

  3. #3
    Join Date
    Jul 2015
    Location
    Austria
    Posts
    20
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Multiple GraphicEffects on QLabel

    Oh ty! I feel so stupid ... i didn´t find the method it in the QLabel class, before i searched for image/effects in qt and found something.
    Another question: how can i change the brightness/contrast/hue of an image?

  4. #4
    Join Date
    Jul 2015
    Location
    Austria
    Posts
    20
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Multiple GraphicEffects on QLabel

    can you give me an example of how to use it? do i need to create the effect on my own then(using patiners)?

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    315
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Multiple GraphicEffects on QLabel

    Qt has no image transformation tools other than the 4 graphics effects in the library. If you want to do other image processing, you will have to research the algorithms on your own and implement them as classes derived from the graphics effect base class. If you want to create an image processing pipeline, then I'd suggest you create another class derived from QGraphicsEffect that implements the pipeline and provides methods for layering effects as you wish. Install your pipeline class as the graphics effect that will be used by the QLabel.

Similar Threads

  1. geting QLabel text ontop of other QLabel displaying image
    By krystosan in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2013, 17:35
  2. QLabel - text in multiple colors
    By galhajaj in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2012, 15:09
  3. QLabel with multiple layers
    By augusbas in forum Qt Programming
    Replies: 4
    Last Post: 16th June 2011, 14:10
  4. Replies: 4
    Last Post: 29th July 2010, 05:07
  5. Replies: 1
    Last Post: 29th September 2009, 19:44

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.