Hi

Using Qt3.3.3. I have a QToolbutton derive class where I am trying use a style to help the button to conform to OS GUI used. I can set the QStyle drawPrimitive or QStyle drawComplex so the graphic is what I want however I cannot change the colour to indicate for example hover or mouse click.

Qt Code:
  1. //++ ------------------------------------------------------------------------------------
  2. void RDWinWithWinMenuBtn_c::paintEvent( QPaintEvent * /*vpEvent*/ )
  3. {
  4. // RD_DEV_IOR_FACT
  5. // The colorGroup parameter in drawComplexControl appears not to be used (look at Qt source code)
  6. // so doing this
  7. // QColorGroup colorGrp; <- default all black
  8. // makes not difference to the button color!!
  9. //
  10. // Also style does not change when windows theme changes. Is this not the idea of QStyles?
  11.  
  12. QPainter painter( this );
  13. //style().drawComplexControl( QStyle::CC_ToolButton, &painter, this, rect(), colorGroup() );
  14.  
  15. // Test code to change to ANY color or style! Not!
  16. QStyle::SFlags sf = QStyle::Style_Raised;
  17. QPalette pl = palette();
  18. QColorGroup cga = pl.active();
  19. QColorGroup cgi = pl.inactive();
  20. QColorGroup cgBtn;
  21. if( hasMouse() )
  22. {
  23. if( m_bBtnIsClicked )
  24. {
  25. sf = QStyle::Style_Down;
  26. cga.setColor( QColorGroup::Background, QColor( Qt::green ) );
  27. cgBtn = cga;
  28. }
  29. else
  30. {
  31. sf = QStyle::Style_HasFocus;
  32. cgi.setColor( QColorGroup::Background, QColor( Qt::blue ) );
  33. cgBtn = cgi;
  34. }
  35. }
  36.  
  37. pl.setActive( cga );
  38. pl.setInactive( cgi );
  39. setPalette( pl );
  40. style().drawControl( QStyle::CE_PushButton, &painter, this, rect(), cgBtn, sf );
  41. }
  42.  
  43. void RDWinWithWinMenuBtn_c::mousePressEvent( QMouseEvent * vpEvent )
  44. {
  45. m_bBtnIsClicked = true;
  46. }
  47.  
  48. void RDWinWithWinMenuBtn_c::mouseReleaseEvent( QMouseEvent * vpEvent )
  49. {
  50. m_bBtnIsClicked = false;
  51. }
To copy to clipboard, switch view to plain text mode 

How do I get the style colour to be used? ATM I see a button but it does not 'animate' to show the user it is active or clicked on. It makes no difference what a style flag or colorGroup I feed it.