Results 1 to 2 of 2

Thread: qCheckbox back ground color

  1. #1
    Join Date
    Feb 2006
    Posts
    60
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default qCheckbox back ground color

    Hi,
    i set the qCheckbox coloring using setPalette(), but it changes the background color of text beside checkbox.
    I want to change the color of the checkbox (the small box where we can check and uncheck the option) and not the text.

    please provide any code snippet if possible

    regards

  2. #2
    Join Date
    Dec 2006
    Posts
    9
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qCheckbox back ground color

    The QPalette::Base role is responsible for the color of the box.

    The following snippet would set it do blue.
    Qt Code:
    1. QCheckBox cb ( "A CheckBox" );
    2.  
    3. QPalette p = cb.palette( );
    4. QColor blue( 0, 0, 255 );
    5. p.setColor( QPalette::Active, QPalette::Base, blue );
    6. cb.setPalette( p );
    To copy to clipboard, switch view to plain text mode 

    See
    http://doc.trolltech.com/4.2/qpalett...ColorRole-enum
    This also should solve your QComboBox problem.

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

    sreedhar (21st December 2006)

Similar Threads

  1. qcombobox back ground coloring
    By sreedhar in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2006, 19:29
  2. problem with the back ground image
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2006, 21:34

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.