Results 1 to 4 of 4

Thread: How to change defualt color of QCheckbox box?

  1. #1
    Join Date
    Oct 2007
    Posts
    39
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question How to change defualt color of QCheckbox box?

    I want to change the default color of QCheckbox box (base ).

    I have tried with
    QPalette p;
    p.setColor(QPalette::Base, QColor(255,0,0));
    qCheckBox.setPalette(pal);

    The above code works in Qt 4.3.3 with Qt3Support
    Please guide me how to implement for Qt 4.4
    Darshan

  2. #2
    Join Date
    Nov 2008
    Location
    Berlin, Germany
    Posts
    13
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded PyQt3 PyQt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: How to change defualt color of QCheckbox box?

    For QCheckbox you need to use the QPalette::Button role as background. You can set the color roles by:
    setBackgroundRole (QPalette::Button);
    setForegroundRole (QPalette::ButtonText);
    and use them by:
    pal.setColor (backgroundRole(), background_color);

  3. #3
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to change defualt color of QCheckbox box?

    have a look at style sheets: stylesheet

  4. #4
    Join Date
    Oct 2007
    Posts
    39
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Thumbs up Re: How to change defualt color of QCheckbox box?

    Hi,

    To set the user-defined colors in the base of QCheckBox, I have to set the style as
    qCheckBoxObj->setStyle(new QWindowStyle);

    And also,
    QPalette p;
    p.setColor(QPalette::Base, QColor(255,0,0));
    qCheckBox.setPalette(pal);

    The color is seen in my case.

    Thanks for your replies......
    Darshan

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.