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. How to make TabBar Labels Horizontal on Orientation West/East, but not breaking fusion Palettes?

How to make TabBar Labels Horizontal on Orientation West/East, but not breaking fusion Palettes?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtabbarcppqt5.12.xlabelqproxystyle
2 Posts 1 Posters 455 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 19 Nov 2021, 10:35 last edited by BDC_Patrick
    #1

    Hi there..

    First of all, this Topic is linked to: this Topic, since i think it got lost.. and is still unsolved..

    I want to have the Labels of a specific TabBar being shown horizontaly, instead of verticaly.
    Therefore, i found this Code snippet here in the Forums:

    #include <QProxyStyle>
    #include <QTabBar>
    #include <QStyleOption>
    #include "tgs_globals.h"
    
    class TGS_CustomTabWest : 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);
        }
    };
    

    posted by @MRJJ.

    The problem is, that this Snippet kills the fusion Palette colors.
    Since i applied a Darkmode Color Palette, my texts are white with a dark grey backdrop Color.

    The Color palette can be changed during runtime by changing the Color Palette from "lightPalette" to "darkPalette" and vise versa.

    The problem now, is this:
    QProxyStyle_Problem.jpg

    On the Left, the default behaviour of a QTabBar. On the Right, The horizontal Labels, as i wish them to be, but the Colors are completely broken.

    setting the Palette to the desired one, after changing the Style, is not working. setting Stylesheet after setting this Style.. not working..

    The Application should use the fusion style with custom palettes.

    I´ve no clue what @SGaist meant with "not overriding drawControl", since i´ve not done that snippet and didn´t know how to not override that things.. never used ProxyStyle before.. and this will be the only need of using ProxyStyle in the whole app.. just for this TabBar ^^".

    Perhaps, someone can help me out here..

    Ps.: TabWidget is created with QT Designer.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      BDC_Patrick
      wrote on 23 Nov 2021, 13:46 last edited by
      #2

      Anyone?
      T_T

      1 Reply Last reply
      0

      1/2

      19 Nov 2021, 10:35

      • 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