You do this by styling the QCheckBox::indicator sub-control.
The style sheet in you example above is malformed, which may explain why you cannot make it work outside Designer. You should quote the font name to avoid any possible confusion caused by the space and you should either specify the size and name together with font: or use font-family: and font-size: to set them separately.
// This
cb.setStyleSheet("font: 36pt 'Comic Sans MS';");
// or this
cb.setStyleSheet("font-size: 36pt; font-family: 'Comic Sans MS';");
// Styling indicator
cb.setStyleSheet(
"QCheckBox {font-size: 36pt; font-family: 'Comic Sans MS'; }"
"QCheckBox::indicator { width: 32px; height: 32px; }"
"QCheckBox::indicator:unchecked { image: url(checkbox_unchecked.png); } "
"QCheckBox::indicator:checked { image: url(checkbox_checked.png); } "
);
cb.show();
QCheckBox cb("Test Check box");
// This
cb.setStyleSheet("font: 36pt 'Comic Sans MS';");
// or this
cb.setStyleSheet("font-size: 36pt; font-family: 'Comic Sans MS';");
// Styling indicator
cb.setStyleSheet(
"QCheckBox {font-size: 36pt; font-family: 'Comic Sans MS'; }"
"QCheckBox::indicator { width: 32px; height: 32px; }"
"QCheckBox::indicator:unchecked { image: url(checkbox_unchecked.png); } "
"QCheckBox::indicator:checked { image: url(checkbox_checked.png); } "
);
cb.show();
To copy to clipboard, switch view to plain text mode
Bookmarks