QTabBar "Paint Event" & Stylesheet Conflicting
Locked
Unsolved
General and Desktop
-
I am painting my own tabbar to create the blinking effect but i also have to style the tabbar so i also have this stylesheet but it is removing the blinking effect is there a work around to this?
I have found few ways searching the internet but i don't think it will work in my case and also not sure how to apply it.
#These Are :
- QAnimation
- Dynamically change stylesheet
#My Paint Function :
void customTabBar::paintEvent(QPaintEvent *event) { QTabBar::paintEvent(event); QStylePainter painter(this); QStyleOptionTab opt; customTabWidget *parentTabWidget = qobject_cast<customTabWidget *>(parentWidget()); for (int i = 0; i < count(); i++) { initStyleOption(&opt, i); if (AlertList.contains(parentTabWidget->widget(i)) && on == true) { opt.palette.setColor(QPalette::Button, Qt::red); painter.drawControl(QStyle::CE_TabBarTab, opt); } if (PinList.contains(parentTabWidget->widget(i))) { opt.palette.setColor(QPalette::Button, Qt::blue); painter.drawControl(QStyle::CE_TabBarTab, opt); } } }
#My stylesheet :
QTabBar::tab { margin-left: 2px; background: #373638; color: #f8f8f2; padding-left: 20px; padding-right: 20px; border-bottom-color: transparent; padding-top: 1px; padding-bottom: 1px; border-radius: 2px; } QTabBar::tab:selected{ margin-left: 2px; background-color: #535455; color: #f8f8f2; padding-left: 20px; padding-right: 20px; padding-top: 1px; padding-bottom: 1px; border-bottom-color: transparent; border-radius: 2px; }
-
-