Results 1 to 4 of 4

Thread: QPalette on PushButton

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile QPalette on PushButton

    hi friends,
    i try to display different color with respect to the input ..

    so to set the color value i use three variable rd , gr , bl and i use it as QColor(rd,gr,bl)

    using i program as

    Qt Code:
    1. p.setColor(QPalette::Background,QColor(rd,gr,bl));
    2. Button->setPalette(p);
    3. 1Button->setPalette(p);
    4. 2Button->setPalette(p);
    5. 3Button->setPalette(p);
    6. 1Label->setPalette(p);
    7. 2Label->setPalette(p);
    8. 1Label->setPalette(p);
    9. 2Label->setPalette(p);
    To copy to clipboard, switch view to plain text mode 

    here all the labels are displaying the color but
    pushButtons are not displaying the background colors ... why?

    i enabled the autofillBackground() also ... if it is not possible then there is any other way to change the color effect according to input ie using a variable for setting color ... ?

    please help
    thanks in advance

  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: QPalette on PushButton

    Open QPalette docs and take a look at the picture. You should use QPalette::Button. You could also have searched the forums....

    PS. Your profile says "X11" so I won't even mention about the famous XP problem.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    wagmare (30th January 2009)

  4. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPalette on PushButton

    thanks for reply
    just a minute before i solve seeing docs clearly

    Button->setPalette(QPalette(QColor(rd,gr,bl)));

    is working fine ....

  5. #4
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPalette on PushButton

    but the document says
    use the colors in the palette rather than hard-coding specific color

    so is there any other way to change the color of the QPushButton using variable color values at differtent times ...
    please help
    thanks in advance

Similar Threads

  1. Help me to load one form over another form PushButton
    By wagmare in forum Qt Programming
    Replies: 7
    Last Post: 26th November 2008, 16:11
  2. Problem with setFont for a PushButton
    By arunvv in forum Newbie
    Replies: 12
    Last Post: 7th April 2008, 23:35
  3. QPalette works differently on windows and linux
    By babu198649 in forum Newbie
    Replies: 3
    Last Post: 6th March 2008, 07:27
  4. connecting image to a pushbutton
    By sudheer in forum Qt Tools
    Replies: 2
    Last Post: 4th December 2007, 09:23
  5. Replies: 1
    Last Post: 2nd July 2007, 16:29

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.