Results 1 to 5 of 5

Thread: Adding shadow effects to QPainter, QLabels and QPushButtons

  1. #1
    Join Date
    Sep 2010
    Posts
    28
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Adding shadow effects to QPainter, QLabels and QPushButtons

    I've created my first GUI, mostly using QPainter, QLabels and QPushButtons. I've done a lot of white, but since the background sometimes will change to black, I need to add some sort of shadow / glow effect around my elements.

    QPainter: The only clue I've found here is using a gradient brush as my pen. The problem is that the gradient is specified from an absolute coordinate, but I would like the centre of the gradient to always be at my pen-tip.

    QPushButtons: Using stylesheets I've created colored buttons with white borders, but have no idea how to add shadows on the outside of the borders.

    QLabels: Not a clue, but maybe I can use drawText instead, if I get my painter working?
    Last edited by anr78; 3rd September 2010 at 10:23. Reason: Typo.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Adding shadow effects to QPainter, QLabels and QPushButtons

    What is exactly that you want to do? I have trouble grasping your needs... Have you seen QGraphicsDropShadowEffect? It's suitable for widgets too.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2010
    Posts
    28
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Adding shadow effects to QPainter, QLabels and QPushButtons

    I have tested QGraphicsDropShadowEffect, but couldn't get it to do what I want.

    Simply said (I hope), what I want to do is to add a soft black border around the white text in my qlabels, the white lines I paint with QPainter, and the white-bordered QPushButtons. This is because my gui is overlayed on video, and I want it to be clear both on black and white background. (And I need to use the white color).

    Hope that explains it.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Adding shadow effects to QPainter, QLabels and QPushButtons

    Oh, ok... you want shadow around text, not around widgets. Probably the easiest way to do it globally is to supply your own QStyle implementation for text-related elements.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2010
    Posts
    28
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Adding shadow effects to QPainter, QLabels and QPushButtons

    I want it around both
    Thanks for the answers.

Similar Threads

  1. Replies: 8
    Last Post: 8th May 2009, 09:14
  2. Where is my QPushButtons
    By HelloDan in forum Qt Programming
    Replies: 4
    Last Post: 30th March 2009, 07:15
  3. How to draw soft shadow with QPainter?
    By troorl_ua in forum Qt Programming
    Replies: 9
    Last Post: 13th October 2008, 13:01
  4. Replies: 1
    Last Post: 1st November 2007, 07:25
  5. Mouse Over Event on QPushButtons
    By merry in forum Qt Programming
    Replies: 2
    Last Post: 6th August 2007, 13:23

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.