Results 1 to 4 of 4

Thread: QPushButton color

  1. #1
    Join Date
    Sep 2010
    Posts
    62
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QPushButton color

    Hello,

    I have a checkable QPushButton and I'd like to change its color when checked.
    I've change the palette colors accordingly, but in the checked state the button is "dimmed" (dithered) as in the attached screendump.
    I am working on LINUx, application style is "Windows".

    How can I get rid of this dithering?

    Thanks for your help
    Attached Images Attached Images

  2. #2
    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: QPushButton color

    It's the selection/focus rect. One way to avoid that is to subclass the buttons paint event and remove the focus state before calling the base class paint event. There are some examples in that forum on how to do that, use the search because I don't know the url right now.

  3. #3
    Join Date
    Sep 2010
    Posts
    62
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QPushButton color

    Thank you,

    I've already solved the problem setting the stylesheet:

    "QPushButton:checked "
    "{"
    " background-color: yellow; "
    " border-width: 2px; "
    " border-style: solid; "
    " border-top-color: rgb(64,64,0); "
    " border-left-color: rgb(64,64,0); "
    " border-right-color: rgb(96,96,0);"
    " border-bottom-color: rgb(96, 96, 0); "
    "}"

    regards,

    me

  4. #4
    Join Date
    Sep 2012
    Posts
    32
    Thanks
    18
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QPushButton color

    Quote Originally Posted by lotek View Post
    Thank you,

    I've already solved the problem setting the stylesheet:

    "QPushButton:checked "
    "{"
    " background-color: yellow; "
    " border-width: 2px; "
    " border-style: solid; "
    " border-top-color: rgb(64,64,0); "
    " border-left-color: rgb(64,64,0); "
    " border-right-color: rgb(96,96,0);"
    " border-bottom-color: rgb(96, 96, 0); "
    "}"

    regards,

    me

    Hi,

    Can i know how to get the background color of a label.

    in my App i am using a tmp variable and managing the color change.

    i.e.,

    int LSSIT_bgcolor;

    if(!(LSSIT_bgcolor==240))
    {
    ui->Label_LSSIT->setStyleSheet("background-color: rgb(255, 153, 0)");
    LSSIT_bgcolor=240;
    }
    if(LSSIT_bgcolor==240)
    {
    ui->Label_LSSIT->setStyleSheet("background-color: rgb(221, 221, 255)");
    LSSIT_bgcolor=241;
    }

    Now what i need is instead a of using an extra variable like "LSSIT_bgcolor" to be used in if condition is their any other way ?
    So that i can know what the color already is applied to my Label.

Similar Threads

  1. QPushButton with MANY text color
    By somename in forum Newbie
    Replies: 8
    Last Post: 30th May 2010, 14:38
  2. QPushButton SetText Color
    By Qt Coder in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2009, 17:21
  3. QPushbutton background color
    By omega36 in forum Qt Programming
    Replies: 27
    Last Post: 31st October 2008, 12:47
  4. QPushButton color when clicked
    By ntp in forum Qt Programming
    Replies: 3
    Last Post: 30th April 2008, 18:34
  5. How to change color of a QPushButton?
    By vishal.chauhan in forum Qt Programming
    Replies: 6
    Last Post: 5th March 2008, 13:22

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.