You can use setItemDelegate method of the treeview to setup custom paint procedure for your treeview items. In the paint method you of the deligate you can remove QStyle::State_HasFocus style from the items options and execute the base painting routine. Below is an example, sorry it's c++.
...
NoFocusDelegate* delegate = new NoFocusDelegate();
ui->treeView->setItemDelegate(delegate);
...
class NoFocusDelegate : public QStyledItemDelegate
{
protected:
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
};
void NoFocusDelegate::paint(QPainter* painter, const QStyleOptionViewItem & option, const QModelIndex &index) const
{
QStyleOptionViewItem itemOption(option);
if (itemOption.state & QStyle::State_HasFocus)
itemOption.state = itemOption.state ^ QStyle::State_HasFocus;
QStyledItemDelegate::paint(painter, itemOption, index);
}
update0: removing QFocusFrame from being drown over a TReeView using custom QStyle object. Below is an example of custom QMotifStyle style descendant (I guess in your case I guess it should be a QMacStyle descendant) which is applied to the application object. It doesn't do any frame rectangle painting whenever it detects a qtreeview widget
class MyStyle1 : public QMotifStyle
{
public:
MyStyle1()
{
//???
}
void drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget = 0 ) const
{
if (element==CE_FocusFrame)
{
const QFocusFrame* frame = qobject_cast<const QFocusFrame*>(widget);
if (frame && frame->widget())
{
QTreeView* treeView = qobject_cast<QTreeView*>(frame->widget());
if (treeView)
{
qDebug() << "no CE_FocusFrame for QFocusFrame over QTreeViews";
return;
}
}
}
QMotifStyle::drawControl(element, option, painter, widget);
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCDEStyle style;
a.setStyle(new MyStyle1());
//a.setStyle(new QMotifStyle());
MainWindow w;
w.show();
return a.exec();
}
hope this helps, regards