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. Vertical Tabbar, with horizontal text, not getting the right Palette

Vertical Tabbar, with horizontal text, not getting the right Palette

Scheduled Pinned Locked Moved Unsolved General and Desktop
tabbarsetstylepalettedark modelight mode
2 Posts 2 Posters 460 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.
  • B Offline
    B Offline
    BDC_Patrick
    wrote on 1 Oct 2021, 11:19 last edited by
    #1

    Hi there.. again..

    I managed to change my Fusion Style color palette from light to dark and vise versa.
    But now, i stumble across another Problem with that Method.

    In some of my Windows, i need a vertical TabBar, that holds Tabs with Horizontal Text.
    To achive this, i took this snippet of code:

    #include <QProxyStyle>
    
    class WestTabH_Text : public QProxyStyle {
    public:
      QSize sizeFromContents(ContentsType type, const QStyleOption* option,
                             const QSize& size, const QWidget* widget) const {
        QSize s = QProxyStyle::sizeFromContents(type, option, size, widget);
        if (type == QStyle::CT_TabBarTab) {
          s.transpose();
        }
        return s;
      }
    
      void drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const {
        if (element == CE_TabBarTabLabel) {
          if (const QStyleOptionTab* tab = qstyleoption_cast<const QStyleOptionTab*>(option)) {
            QStyleOptionTab opt(*tab);
            opt.shape = QTabBar::RoundedNorth;
            QProxyStyle::drawControl(element, &opt, painter, widget);
            return;
          }
        }
        QProxyStyle::drawControl(element, option, painter, widget);
      }
    };
    

    And set it as Style for the TabBar

    ui->TabView_Database->tabBar()->setStyle(new WestTabH_Text);
    

    Looks great in standard fusion light Theme... but gives me a Problem in the dark one.. see:
    Unbenannt.jpg

    I´m not familiar with the Palette and Style thing.. so it would be nice, if you People can help me out here.. How can i set the Style of the TabBar to fit the current Palette?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 1 Oct 2021, 18:29 last edited by
      #2

      Hi,

      My guess is that it still wraps the previous style.
      I would recreate the proxy style when switching between your themes.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      1 Oct 2021, 11:19

      • Login

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