Horizontal text in QTabWidget

  • Hello!

    I am trying to put the tab text in horizontal. I put the tabs in west orientation but the text appears in vertical like this picture:


    Anybody knows how to put this texts horizontal?

    Thank you very much!!

  • Qt Champions 2016

    You can use a QProxyStyle.
    First time is a bit WTF so here an example.

    class CustomTabStyle : public QProxyStyle {
      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) {
        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);
        QProxyStyle::drawControl(element, option, painter, widget);

    and set it
    ui->tabWidget->tabBar()->setStyle(new CustomTabStyle);

    alt text

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.