Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTabBar "Paint Event" & Stylesheet Conflicting
Forum Updated to NodeBB v4.3 + New Features

QTabBar "Paint Event" & Stylesheet Conflicting

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 185 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Narutoblaze
    wrote on 30 Nov 2023, 15:33 last edited by Narutoblaze
    #1

    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;
    }
    
    C 1 Reply Last reply 30 Nov 2023, 18:06
    0
    • N Narutoblaze
      30 Nov 2023, 15:33

      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;
      }
      
      C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 30 Nov 2023, 18:06 last edited by
      #2

      Dupe of https://forum.qt.io/topic/152497/qtabbar-paint-event-stylesheet-conflicting

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • C Christian Ehrlicher locked this topic on 30 Nov 2023, 18:06

      2/2

      30 Nov 2023, 18:06

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved