Results 1 to 2 of 2

Thread: Problem with qtoolbutton

  1. #1
    Join Date
    Aug 2006
    Posts
    83

    Default Problem with qtoolbutton

    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.

  2. #2
    Join Date
    Aug 2006
    Posts
    83

    Default Re: Problem with qtoolbutton

    I've solved it. I had to implement QEvent::FocusOut and QEvent::FocusIn events

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 13:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 13:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 15:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 22:36
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.