Results 1 to 7 of 7

Thread: How to change color of a QPushButton?

  1. #1
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question How to change color of a QPushButton?

    Hi All,

    I am working on Qt 4.3.3 on my Mac 10.4.11.

    I have a QPushButton and I want that its color should not be white as the default color.
    so how should I change the color of the QPushButton also when I checked it the selected color is aqua so I also want to change that color.

    So how should I do it?

    Thanks.
    Vishal

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to change color of a QPushButton?

    Please search the forums before starting new threads. This question has been answered many many times.
    J-P Nurmi

  3. #3
    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: How to change color of a QPushButton?


  4. #4
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to change color of a QPushButton?

    I am using the code method.

    That is I am setting like this
    Qt Code:
    1. btn_Show->setStyleSheet("color: #0000dd; background-color: red;");
    To copy to clipboard, switch view to plain text mode 

    But nothing changes. I am drawing the custom Button(just implementing the enter and leave event).

    As I reading setStyleSheet it does not support QMacStyle so Is there any other way I can achieve this.
    Last edited by vishal.chauhan; 5th March 2008 at 12:50.

  5. #5
    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: How to change color of a QPushButton?

    Did you reimplement the paintEvent? Could you show us the code?

  6. #6
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to change color of a QPushButton?

    Actually it does not support on QMacStyle if I changes the style to some other style the color changes but I need this on QMacStyle.

  7. #7
    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: How to change color of a QPushButton?

    Change the style of this particular widget then. All the rest of the application will remain unchanged.

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. 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.