[SOLVED] Grey out/Disable the QCheckBox text in Qt
-
I am working on a sample app where I need to disable the text of checkbox when checkbox is not checked and enable it when checkbox is checked.
Code:
@if(ui->checkBox->isChecked() == true)
{
// Enable the text of checkbox
}else
{
// Disable the text of checkbox
}@I have looked through various articles but I haven't got the right solution. Please help :)
-
Yes i used. I tried this:
@ui->checkBox->setStyleSheet( "QCheckBox::indicator:checked { {color: black;} } QCheckBox::indicator:unchecked {{color: grey;}}");@
But again this doesnt seem to work. Am i making a mistake???
[quote author="qxoz" date="1366802036"]Hi!
You can experiment with qss. But as a fast solution you can use checkbox(without text)+label combination. That's maybe not rightest but fast :)[/quote] -
Thanks brother :) It works
[quote author="qxoz" date="1366802657"]This works for me:
@QCheckBox:checked{color: black;}
QCheckBox:unchecked{color: grey;}@
or
@QCheckBox#checkBox:checked{color: black;}
QCheckBox#checkBox:unchecked{color: grey;}@
[/quote]