0

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.

enter image description here

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.

enter image description here

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 ?

Pamputt
  • 173
  • 1
  • 11
Mike Finch
  • 746
  • 1
  • 7
  • 20
  • 1
    I would guess you're using a high-dpi display with an ancient Qt version which can not handle it. – chehrlic Jul 15 '23 at 12:26

0 Answers0