Results 1 to 4 of 4

Thread: QPushButton image doesn't show transparency

  1. #1
    Join Date
    Nov 2013
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QPushButton image doesn't show transparency

    Hi,

    I want to add an image to QPushButton for "normal" state and an image for "pressed" state by using StyleSheets. The issue I am having is that transparency of the image doesn't seem to work well, I see the square shape of the icon even though the icon is completely transparent.
    Does anyone have a an idea why this is happening ?

    Here is my stylesheet code and a screenshot of the QPushButton. You can see the square with slightly different color than the background, almost as if it's partially transparent.

    Qt Code:
    1. QPushButton#settingsButton {
    2. image: url(transparent_icon.png);
    3. border:none;
    4. outline:none;
    5. width: 64px;
    6. height: 64px;
    7. }
    8.  
    9.  
    10. QPushButton#settingsButton:pressed {
    11. image: url(transparent_icon.png);
    12.  
    13. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QPushButton image doesn't show transparency

    You have applied a gradient background that is cascading down and applying to the QPushButton. A transparent icon over a gradient background shows the background.

  3. #3
    Join Date
    Nov 2013
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPushButton image doesn't show transparency

    It does look like it but I didn't. The icon has no gradient applied. When I use [code] settingsButton.setStylesheet() [\code] then the icon is transparent and I see the background. Why is there a difference?

  4. #4
    Join Date
    Nov 2013
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPushButton image doesn't show transparency

    So I checked this again and it seems I get transparency of the icon when I write code in .cpp. But when I write it in .qss then I don't. Any thoughts anyone?

Similar Threads

  1. QPushButton doesn't show with a particular text.
    By bwnicewo in forum Qt Programming
    Replies: 0
    Last Post: 30th July 2013, 22:09
  2. Transparency doesn't work in building Qt from sources
    By AspiringEngineer in forum Qt Programming
    Replies: 0
    Last Post: 18th June 2013, 15:31
  3. QPushButton Icon opacity/transparency
    By vladozar in forum Qt Programming
    Replies: 2
    Last Post: 26th November 2012, 17:45
  4. Replies: 9
    Last Post: 8th November 2011, 16:54
  5. Replies: 3
    Last Post: 8th September 2011, 16:45

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.