I am using Qt version 4.7.4 to build a Windows app.
The checkmark in a QCheckBox
is very small and is left-top aligned in the corner. Here is a snippet of a QCheckBox
in my app.
And, the problem is not just with my app. When I use the Qt Designer that comes with this version of Qt, all the checkboxes there have the same problem. Here is a snippet of a few checkboxes in Qt Designer.
I have tried changing the stylesheet for QCheckBox
without success. I can change some things via the stylesheet, such as the background color. But when I attempt to change the images used for the indicator part of the QCheckBox
, nothing appears.
I have been following the examples from:
Here are the style rules I am testing.
// MainWindow constructor. MainWindow derives from QMainWindow.
MainWindow::MainWindow( QWidget * pParent, Qt::WFlags flags )
: QMainWindow( pParent, flags )
{
...
QStringList styles;
// Force checkboxes to have checkmarks that are easier to see.
// As a sanity check, changing the background color works.
styles << "QCheckBox { background-color: rgb( 0, 255, 0 ); }";
// This does not work. The checkbox border still renders, but nothing inside the border appears.
styles << "QCheckBox::indicator { width: 32px; height: 32px; }";
styles << "QCheckBox::indicator:checked { image: url(:/resources/big_check_32x32.png); }";
styles << "QCheckBox::indicator:unchecked { image: url(:/resources/big_uncheck_32x32.png); }";
setStyleSheet( styles.join( " " ) );
}
The paths I am using to reference the app's embedded image resources could be wrong. I have never tried it this way before. I previously always referenced an embedded image resource via its alias, which works for a QIcon
.
Is there a better way to fix the very small checkmark in a QCheckBox
?