Results 1 to 6 of 6

Thread: Background Color of QToolButton or QPushButton

  1. #1
    Join Date
    Jul 2009
    Posts
    39
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Background Color of QToolButton or QPushButton

    When I changed a QToolButton or QPushButton's background color by using StyleSheet, I lose button effects and they seem like labels.
    Do you have any idea, how can I change colors of QToolButton and QPushButton without losing button effects?

    Thanks.

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Background Color of QToolButton or QPushButton

    You cannot control that. This happens with style sheet. For better results use different background colors for normal, hover, pressed. So it will look better.
    More info here.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Background Color of QToolButton or QPushButton

    That's wired. Can't reproduce your problem. Have you tried QPalette for changing the color?

    Edit: you mean the appearance, not the functionality. Of course you get a flat button if you set the color via style sheets. That's the wanted effect. But as said use QPalette.

  4. #4
    Join Date
    Jul 2009
    Posts
    39
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Background Color of QToolButton or QPushButton

    No, I didn't try QPalette, I'm using StyleSheet for other changes and I want to change everthing in same way.

    yogeshgokul, thanks for the link.

    Quote Originally Posted by Lykurg View Post
    That's wired. Can't reproduce your problem. Have you tried QPalette for changing the color?

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Background Color of QToolButton or QPushButton

    Quote Originally Posted by metdos View Post
    No, I didn't try QPalette, I'm using StyleSheet for other changes and I want to change everthing in same way.
    If so and you want to have a 3d effect on the buttons you have to use images (or use gradients if they fit your needs).

  6. #6
    Join Date
    May 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Background Color of QToolButton or QPushButton

    if you want to change the stylesheet only for qtoolbutton u write qApp->setStyleSheet("QToolButton{....css...}")
    qtool button inherts qpushbutton so if u want to have different css...1st style the qpushbutton and after the qtoolbutton....it will work..i hope..(sry for my english)

Similar Threads

  1. Change background color of QPushButton
    By gtthang in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2013, 10:23
  2. Change QPushButton Background Color, Qt4.3
    By Rayven in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2009, 07:14
  3. Replies: 1
    Last Post: 15th March 2009, 20:02
  4. QToolButton & QPushButton
    By hrcariaga in forum Qt Programming
    Replies: 5
    Last Post: 15th July 2008, 21:17
  5. Change background color for a QPushButton?
    By Harvey West in forum Qt Programming
    Replies: 6
    Last Post: 5th January 2007, 14:23

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.