Hi
I'm trying to show a bool value with a QCheckBox, that the user shouldn't be able to change, but without changing the appearance of the QCheckBox.
This is what I've got so far:
checkBox->setEnabled(false);
checkBox->setPalette(palette);
checkBox->setEnabled(false);
QPalette palette(checkBox->palette());
palette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(Qt::black));
checkBox->setPalette(palette);
To copy to clipboard, switch view to plain text mode
That changes the text color back to black, but the checked indicator still is grey.
I tried to change it with a style-sheet:
checkBox->setStyleSheet("::indicator { border-color: black; }");
checkBox->setStyleSheet("::indicator { border-color: black; }");
To copy to clipboard, switch view to plain text mode
...with that the indicator isn't visible.
checkBox->setStyleSheet("::indicator { width: 12px; height: 12px; border-width: 1px; border-style: solid; border-color: black; }");
checkBox->setStyleSheet("::indicator { width: 12px; height: 12px; border-width: 1px; border-style: solid; border-color: black; }");
To copy to clipboard, switch view to plain text mode
... with that it is, but it just looks weird, plus the check doesn't show.
There has to be a simpler way.
I already thought about just connecting the QCheckBox toggled(bool checked) signal to a slot connected to:
void::myClass checkBoxToggled(bool checked)
{
checkbox->setChecked(whatever I need);
}
void::myClass checkBoxToggled(bool checked)
{
checkbox->setChecked(whatever I need);
}
To copy to clipboard, switch view to plain text mode
..or something like that.
Any suggestions?
Bookmarks