Now what beautiful the life would have been if every widget had a function like this

void setFocusRectangleVisible(bool status)

But no, there is none. So after looking over the entire google, I found this example:

http://qt.nokia.com/developer/faqs/736

which works fine. I took that example and replaced some things in there to use it on my QTreeWidget.

Now I have this

Qt Code:
  1. void Style::drawControl(ControlElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget ) const
  2. {
  3. if(element == CE_ItemViewItem)
  4. {
  5. const QStyleOptionViewItem *b = qstyleoption_cast<const QStyleOptionViewItem *>(option);
  6.  
  7. if (btn)
  8. {
  9. if (btn->state & State_HasFocus)
  10. {
  11. btn->state = btn->state ^ State_HasFocus;
  12. }
  13. }
  14.  
  15. QWindowsStyle::drawControl(element, btn, painter, widget);
  16.  
  17. }
  18. else
  19. {
  20. QWindowsStyle::drawControl(element, option, painter, widget);
  21. }
  22. }
To copy to clipboard, switch view to plain text mode 

This is not working as expected because this test is NEVER true

Qt Code:
  1. if (btn->state & State_HasFocus)
To copy to clipboard, switch view to plain text mode 

Can someone please help me? What am I missing? Is the problem the fact that the focus is not on the item itself, but on the tree widget?

I'm using Qt 4.5