Hi, I'd like to replace the default checkbox with images of my own, but I'm having some difficulties. Just doesn't work, as if nothing is happening. Here is the code where I try to "catch" the checkbox and redraw, keep in mind I don't really know what I'm doing, just feeling my way:

Qt Code:
  1. void ResoStyle::drawControl(ControlElement control, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
  2. {
  3. switch (control)
  4. {
  5. //replaces default CheckBox style with our own
  6. case CE_CheckBox:
  7. if(const QStyleOptionButton * checkOption = qstyleoption_cast<const QStyleOptionButton *>(option))
  8. {
  9. const QCheckBox * checkbox = qobject_cast<const QCheckBox *>(widget);
  10.  
  11. QStyleOptionButton newCheckBox(*checkOption);
  12.  
  13. QRect frame = newCheckBox.rect;
  14.  
  15.  
  16. painter->save();
  17. painter->setBrushOrigin(frame.topLeft());
  18.  
  19. if(newCheckBox.state & State_MouseOver)
  20. {
  21. if(!checkbox->isChecked())
  22. {
  23. painter->drawImage(frame, QImage("./Images/disabled_hover.png"));
  24. }
  25. else
  26. {
  27. //draw the color of the current module class
  28. painter->drawImage(frame, QImage("./Images/personal_enabled.png"));
  29. }
  30. }
  31. else
  32. {
  33. if(!checkbox->isChecked())
  34. {
  35. painter->drawImage(frame, QImage("./Images/disabled_default.png"));
  36. }
  37. else
  38. {
  39. //draw the color of the current module class
  40. painter->drawImage(frame, QImage("./Images/personal_enabled.png"));
  41. }
  42. }
  43. painter->restore();
  44. QCleanlooksStyle::drawControl(control, &newCheckBox, painter, widget);
  45. }
  46. else
  47. {
  48. QCleanlooksStyle::drawControl(control, option, painter, widget);
  49. }
  50. break;
To copy to clipboard, switch view to plain text mode 

One thing I'd also like to understand is, is this the best way to do something like this. Would I also be able to just override the paintEvent for the widget and redraw there just as well?

Thanks for any help you can give...