It seems that the focus rectangle is being handled by QStyle (not to be confused with style sheets), which is used. You can write a subclass of QStyle and apply it to your QTabWidget . The subclass should override the drawControl() method and do nothing if it is currently drawing a focus rectangle.
The subclass will look something like this:
NoFocusRectStyle.h
#ifndef NOFOCUSRECTSTYLE_H #define NOFOCUSRECTSTYLE_H #include <QWindowsVistaStyle> // or the QStyle subclass of your choice class NoFocusRectStyle : public QWindowsVistaStyle { public: NoFocusRectStyle(); protected: void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const; }; #endif // NOFOCUSRECTSTYLE_H
NoFocusRectStyle.cpp
#include "NoFocusStyle.h" NoFocusRectStyle::NoFocusRectStyle() { } void NoFocusRectStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { if(element == CE_FocusFrame) return; QWindowsVistaStyle::drawControl(element, option, painter, widget); }
Somewhere in your intializer / constructor form, you would apply a custom style subclass to the tab widget:
ui->tabWidget->setStyle(new NoFocusRectStyle());
This should allow your style sheets to continue to work.
It would be nice if there was an easier way to do this, but I could not find it :)
source share