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. Left align TabBar on Mac OSX
Forum Updated to NodeBB v4.3 + New Features

Left align TabBar on Mac OSX

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 3 Posters 2.4k Views 3 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    I can't comment on that.

    It was really curiosity about your use case.

    Might be a silly question but did you already checked the QTabBar part of the style sheet documentation ?

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

    T 1 Reply Last reply
    1
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #5

      Hi
      try

      QTabWidget::tab-bar {
          left: 0; 
      }
      
      1 Reply Last reply
      0
      • SGaistS SGaist

        I can't comment on that.

        It was really curiosity about your use case.

        Might be a silly question but did you already checked the QTabBar part of the style sheet documentation ?

        T Offline
        T Offline
        Taytoo
        wrote on last edited by
        #6

        @SGaist said in Left align TabBar on Mac OSX:

        Might be a silly question but did you already checked the QTabBar part of the style sheet documentation ?

        Yes, I tried all the options and they are working on Windows. Not on Mac though

        @mrjj said in Left align TabBar on Mac OSX:

        Hi
        try

        QTabWidget::tab-bar {
            left: 0; 
        }
        

        Not working :(

        mrjjM 1 Reply Last reply
        0
        • T Taytoo

          @SGaist said in Left align TabBar on Mac OSX:

          Might be a silly question but did you already checked the QTabBar part of the style sheet documentation ?

          Yes, I tried all the options and they are working on Windows. Not on Mac though

          @mrjj said in Left align TabBar on Mac OSX:

          Hi
          try

          QTabWidget::tab-bar {
              left: 0; 
          }
          

          Not working :(

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #7

          @Taytoo
          ok then i assume stylesheets cannot do it on OSX.

          T 1 Reply Last reply
          0
          • mrjjM mrjj

            @Taytoo
            ok then i assume stylesheets cannot do it on OSX.

            T Offline
            T Offline
            Taytoo
            wrote on last edited by
            #8

            @mrjj The suggestion give in the stackoverflow answer i.e. use QStyle, how would that work? if I have stylesheet applied to the Tab, would QStyle conflict with it?

            mrjjM 1 Reply Last reply
            0
            • T Taytoo

              @mrjj The suggestion give in the stackoverflow answer i.e. use QStyle, how would that work? if I have stylesheet applied to the Tab, would QStyle conflict with it?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #9

              @Taytoo
              Hi
              The QStyle is the backbone of drawing the widgets. It does respect stylesheets in most cases.

              There is also https://doc.qt.io/qt-5/qproxystyle.html
              which is often used for this kind of override.

              Its something like
              https://stackoverflow.com/questions/29835759/qt-custom-qstyle-for-qtabbar
              but its not full sample you have to fiddle with it to get it to move the actual tab positions.

              T 1 Reply Last reply
              2
              • mrjjM mrjj

                @Taytoo
                Hi
                The QStyle is the backbone of drawing the widgets. It does respect stylesheets in most cases.

                There is also https://doc.qt.io/qt-5/qproxystyle.html
                which is often used for this kind of override.

                Its something like
                https://stackoverflow.com/questions/29835759/qt-custom-qstyle-for-qtabbar
                but its not full sample you have to fiddle with it to get it to move the actual tab positions.

                T Offline
                T Offline
                Taytoo
                wrote on last edited by
                #10

                Can anyone provide an example of how to use QProxyStyle to set tab alignment to left on macOS? I've never worked with QProxyStyle so finding it hard to figure this stuff out, even from documentation

                SGaistS mrjjM 2 Replies Last reply
                0
                • T Taytoo

                  Can anyone provide an example of how to use QProxyStyle to set tab alignment to left on macOS? I've never worked with QProxyStyle so finding it hard to figure this stuff out, even from documentation

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  @Taytoo hi, did you check the link provided by @mrjj ?

                  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
                  1
                  • T Taytoo

                    Can anyone provide an example of how to use QProxyStyle to set tab alignment to left on macOS? I've never worked with QProxyStyle so finding it hard to figure this stuff out, even from documentation

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #12

                    @Taytoo
                    Hi

                    In theory, we should be able to do

                    class TabStyle : public QProxyStyle
                    {
                    public:
                        explicit TabStyle(Qt::Orientation orientation, QStyle *baseStyle = 0)
                            : QProxyStyle(baseStyle) {}
                        virtual int styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget,
                                              QStyleHintReturn *returnData) const override
                        {
                            if (stylehint == SH_TabBar_Alignment )
                                return Qt::AlignLeft; // or right
                    
                            return QProxyStyle::styleHint(stylehint, opt, widget, returnData);
                        }
                    };
                    

                    However, i could not get it to RIGHT align on Windows so it seems Tabbar ignores it.

                    https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qtabbar.cpp.html

                    It goes

                    void QTabBarPrivate::layoutTabs()
                    {
                        Q_Q(QTabBar);
                       ....
                        Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, 0, q));
                    

                    So it seems it should use the hint but my styleHint seems not to have any effect on
                    the tab alignment at all.
                    (always left, regardless of center or right)

                    So im a bit lost but Im using a tab widget and maybe its the reason it get ignored but
                    as far as i know, it's using a tabbar internally.

                    T 1 Reply Last reply
                    1
                    • mrjjM mrjj

                      @Taytoo
                      Hi

                      In theory, we should be able to do

                      class TabStyle : public QProxyStyle
                      {
                      public:
                          explicit TabStyle(Qt::Orientation orientation, QStyle *baseStyle = 0)
                              : QProxyStyle(baseStyle) {}
                          virtual int styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget,
                                                QStyleHintReturn *returnData) const override
                          {
                              if (stylehint == SH_TabBar_Alignment )
                                  return Qt::AlignLeft; // or right
                      
                              return QProxyStyle::styleHint(stylehint, opt, widget, returnData);
                          }
                      };
                      

                      However, i could not get it to RIGHT align on Windows so it seems Tabbar ignores it.

                      https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qtabbar.cpp.html

                      It goes

                      void QTabBarPrivate::layoutTabs()
                      {
                          Q_Q(QTabBar);
                         ....
                          Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, 0, q));
                      

                      So it seems it should use the hint but my styleHint seems not to have any effect on
                      the tab alignment at all.
                      (always left, regardless of center or right)

                      So im a bit lost but Im using a tab widget and maybe its the reason it get ignored but
                      as far as i know, it's using a tabbar internally.

                      T Offline
                      T Offline
                      Taytoo
                      wrote on last edited by
                      #13

                      @mrjj That's what I read online on stackoverflow as well and that particular author suggested modifying qt sources and rebuilding, but i don't know how to do this.

                      Anyone has any idea why qproxystyle isn't working?

                      1 Reply Last reply
                      0

                      • Login

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