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
{
if(element == CE_ItemViewItem)
{
if (btn)
{
if (btn->state & State_HasFocus)
{
btn->state = btn->state ^ State_HasFocus;
}
}
}
else
{
}
}
void Style::drawControl(ControlElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget ) const
{
if(element == CE_ItemViewItem)
{
const QStyleOptionViewItem *b = qstyleoption_cast<const QStyleOptionViewItem *>(option);
QStyleOptionViewItem *btn = (QStyleOptionViewItem *)b;
if (btn)
{
if (btn->state & State_HasFocus)
{
btn->state = btn->state ^ State_HasFocus;
}
}
QWindowsStyle::drawControl(element, btn, painter, widget);
}
else
{
QWindowsStyle::drawControl(element, option, painter, widget);
}
}
To copy to clipboard, switch view to plain text mode
This is not working as expected because this test is NEVER true
if (btn->state & State_HasFocus)
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
Bookmarks