Hello I have a problem with QToolButton:
I want it to have different icons for different states (mouse_over,tab_focus,or none of that). I have implemented an eventFilter and it all works except I don't know how to implement the part where I leave a qtoolbutton with tab_focus, but the icon for that state still stays .
I want it to update itself so it would put the right icon.
here's the part of the code for the event filter :
Qt Code:
  1. if(button)
  2. action = button->defaultAction();
  3.  
  4.  
  5.  
  6. if (event->type() == QEvent::KeyPress)
  7. {
  8. if(strcmp(objName,"LeftWidget")==0)
  9. ctrl->setActionIcon(action,button->hasFocus() ? CPersonalControl::ImageType_Focus : CPersonalControl::ImageType_Normal);
  10. rrr = true;
  11.  
  12. return QObject::eventFilter(obj, event);
  13. }
  14.  
  15. else if (event->type() == QEvent::Enter)
  16. {
  17. //iz objekta dobim ven widget
  18. if(strcmp(objName,"LeftWidget")==0)
  19. {
  20. ctrl->setActionIcon(action,button->hasFocus() ? CPersonalControl::ImageType_Focus : CPersonalControl::ImageType_MouseOver);
  21. }
  22.  
  23. else
  24. {
  25. if(button)
  26. {
  27. if(action->data().canConvert(QVariant::Icon))
  28. {
  29. ikonca = action->icon();
  30. QIcon ikona = action->data().value<QIcon>();
  31. if(!(ikona.isNull()))
  32. button->setIcon(ikona);
  33. }
  34. }
  35. }
  36.  
  37. return QObject::eventFilter(obj, event);
  38. }
  39.  
  40. else if (event->type() == QEvent::Leave)
  41. {
  42. // a widget in the toolbar was left
  43. if(strcmp(objName,"LeftWidget")==0)
  44. ctrl->setActionIcon(action,button->hasFocus() ? CPersonalControl::ImageType_Focus : CPersonalControl::ImageType_Normal);
  45.  
  46. else
  47. {
  48. if(button)
  49. {
  50. if(!(ikonca.isNull()))
  51. button->setIcon(ikonca);
  52.  
  53. }
  54. }
  55.  
  56. return QObject::eventFilter(obj, event);
  57. }
  58.  
  59.  
  60. else
  61. {
  62. // standard event processing
  63. return QObject::eventFilter(obj, event);
  64. }
To copy to clipboard, switch view to plain text mode 

I don't know if I should implement another QEvent or it's something completely else. Please help.