Qt checkbox/toolbutton with custom/distinct check/unchecked icons

This must be entered as a StyleSheet. Do this via the Design editor by right click on the check box and selecting "Change stylesheet...".


Use ::indicator sub-item. the code below works excellent for me...

 QCheckBox::indicator {
     width: 18px;
     height: 18px;
 }

  QCheckBox::indicator:checked
  {
    image: url(.../Checkbox_checked_normal.png);
  }
  QCheckBox::indicator:unchecked
  {
    image: url(.../Checkbox_unchecked_normal.png);
  }

  QCheckBox::indicator:checked:hover
  {
    image: url(.../Checkbox_checked_hovered.png);
  }
  QCheckBox::indicator:unchecked:hover
  {
    image: url(.../Checkbox_unchecked_hovered.png);
  }
  QCheckBox::indicator:checked:pressed
  {
    image: url(.../Checkbox_checked_pressed.png);
  }
  QCheckBox::indicator:unchecked:pressed
  {
    image: url(.../Checkbox_unchecked_pressed.png);
  }
  QCheckBox::indicator:checked:disabled
  {
    image: url(.../Checkbox_checked_disabled.png);
  }
  QCheckBox::indicator:unchecked:disabled
  {
    image: url(.../Checkbox_unchecked_disabled.png);
  }

Tags:

C++

Qt