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. Horizontal text in QTabWidget

Horizontal text in QTabWidget

Scheduled Pinned Locked Moved Solved General and Desktop
25 Posts 8 Posters 13.0k 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.
  • A Offline
    A Offline
    AZEDINE
    wrote on 18 Mar 2025, 11:01 last edited by
    #15

    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:

    en python : class HorizontalTabStyle(QProxyStyle):
    def drawControl(self, element, option, painter, widget=None):
    if element == QProxyStyle.CE_TabBarTab:
    opt_tab = QStyleOptionTab(option)
    # نجعل Qt يرسم النص كما لو كان في الأعلى (North) وبالتالي يكون أفقي
    opt_tab.shape = QTabBar.RoundedNorth
    super(HorizontalTabStyle, self).drawControl(element, opt_tab, painter, widget)
    else:
    super(HorizontalTabStyle, self).drawControl(element, option, painter, widget)
    .....
    self.tabWidgetResult.setTabPosition(QTabWidget.TabPosition.West)

        # نطبّق الستايل المخصص على الـ tabBar
        self.custom_style = HorizontalTabStyle(self.tabWidgetResult.style())
        self.tabWidgetResult.tabBar().setStyle( self.custom_style)
    
    J 1 Reply Last reply 18 Mar 2025, 12:18
    0
    • A AZEDINE
      18 Mar 2025, 11:01

      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:

      en python : class HorizontalTabStyle(QProxyStyle):
      def drawControl(self, element, option, painter, widget=None):
      if element == QProxyStyle.CE_TabBarTab:
      opt_tab = QStyleOptionTab(option)
      # نجعل Qt يرسم النص كما لو كان في الأعلى (North) وبالتالي يكون أفقي
      opt_tab.shape = QTabBar.RoundedNorth
      super(HorizontalTabStyle, self).drawControl(element, opt_tab, painter, widget)
      else:
      super(HorizontalTabStyle, self).drawControl(element, option, painter, widget)
      .....
      self.tabWidgetResult.setTabPosition(QTabWidget.TabPosition.West)

          # نطبّق الستايل المخصص على الـ tabBar
          self.custom_style = HorizontalTabStyle(self.tabWidgetResult.style())
          self.tabWidgetResult.tabBar().setStyle( self.custom_style)
      
      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 18 Mar 2025, 12:18 last edited by
      #16

      @AZEDINE There is no picture. And please format your code properly.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply 18 Mar 2025, 13:44
      0
      • J jsulm
        18 Mar 2025, 12:18

        @AZEDINE There is no picture. And please format your code properly.

        A Offline
        A Offline
        AZEDINE
        wrote on 18 Mar 2025, 13:44 last edited by AZEDINE
        #17

        @jsulm

        
        self.tabWidgetResult = self.findChild(QTabWidget, "tabWidgetResult")
               if self.tabWidgetResult:
                   self.tabWidgetResult.tabBar().setCursor(Qt.CursorShape.PointingHandCursor)
        
        
               self.tabWidgetResult.setStyleSheet("
                   QTabBar::tab {
                       width: 29px;
                       max-width: 100px;
                       min-width: 20px;
                   }
        
                   QTabBar::tab:selected {
                       background: #0E94A0;
                       color: white; 
                   }
        
                   QTabBar::tab {
                       color: #000000; 
                   }
        
                   QTabBar::tab::!selected {
                       color: #0E94A0; 
                   }
        
                   QTabBar::tab {
                       font-size: 14px;
                       font-weight: bold; 
                       margin: 5px; 
                       padding: 5px; 
                       border: 2px solid #0E94A0;
                       border-radius: 10px; 
                   }
        
                   QTabBar::tab > QLabel {
                       qproperty-alignment: AlignCenter; 
                   transform: translate(0,10px) rotate(-90deg);
                           
                   }
        
                   QTabBar::tab:selected > QLabel {
                       qproperty-alignment: AlignCenter; 
                       transform: translate(0,10px) rotate(-90deg);
                       
                   }
        
               ")
               
        

        (Capture d'écran 2025-03-17 152926.png link url)) 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:

        J A 2 Replies Last reply 18 Mar 2025, 14:10
        0
        • A AZEDINE
          18 Mar 2025, 13:44

          @jsulm

          
          self.tabWidgetResult = self.findChild(QTabWidget, "tabWidgetResult")
                 if self.tabWidgetResult:
                     self.tabWidgetResult.tabBar().setCursor(Qt.CursorShape.PointingHandCursor)
          
          
                 self.tabWidgetResult.setStyleSheet("
                     QTabBar::tab {
                         width: 29px;
                         max-width: 100px;
                         min-width: 20px;
                     }
          
                     QTabBar::tab:selected {
                         background: #0E94A0;
                         color: white; 
                     }
          
                     QTabBar::tab {
                         color: #000000; 
                     }
          
                     QTabBar::tab::!selected {
                         color: #0E94A0; 
                     }
          
                     QTabBar::tab {
                         font-size: 14px;
                         font-weight: bold; 
                         margin: 5px; 
                         padding: 5px; 
                         border: 2px solid #0E94A0;
                         border-radius: 10px; 
                     }
          
                     QTabBar::tab > QLabel {
                         qproperty-alignment: AlignCenter; 
                     transform: translate(0,10px) rotate(-90deg);
                             
                     }
          
                     QTabBar::tab:selected > QLabel {
                         qproperty-alignment: AlignCenter; 
                         transform: translate(0,10px) rotate(-90deg);
                         
                     }
          
                 ")
                 
          

          (Capture d'écran 2025-03-17 152926.png link url)) 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:

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 18 Mar 2025, 14:10 last edited by
          #18

          @AZEDINE said in Horizontal text in QTabWidget:

          I put the tabs in west orientation

          According to the picture you don't: the tabs are arranged vertically. How did you set up the QTabWidget?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A AZEDINE
            18 Mar 2025, 13:44

            @jsulm

            
            self.tabWidgetResult = self.findChild(QTabWidget, "tabWidgetResult")
                   if self.tabWidgetResult:
                       self.tabWidgetResult.tabBar().setCursor(Qt.CursorShape.PointingHandCursor)
            
            
                   self.tabWidgetResult.setStyleSheet("
                       QTabBar::tab {
                           width: 29px;
                           max-width: 100px;
                           min-width: 20px;
                       }
            
                       QTabBar::tab:selected {
                           background: #0E94A0;
                           color: white; 
                       }
            
                       QTabBar::tab {
                           color: #000000; 
                       }
            
                       QTabBar::tab::!selected {
                           color: #0E94A0; 
                       }
            
                       QTabBar::tab {
                           font-size: 14px;
                           font-weight: bold; 
                           margin: 5px; 
                           padding: 5px; 
                           border: 2px solid #0E94A0;
                           border-radius: 10px; 
                       }
            
                       QTabBar::tab > QLabel {
                           qproperty-alignment: AlignCenter; 
                       transform: translate(0,10px) rotate(-90deg);
                               
                       }
            
                       QTabBar::tab:selected > QLabel {
                           qproperty-alignment: AlignCenter; 
                           transform: translate(0,10px) rotate(-90deg);
                           
                       }
            
                   ")
                   
            

            (Capture d'écran 2025-03-17 152926.png link url)) 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:

            A Offline
            A Offline
            AZEDINE
            wrote on 18 Mar 2025, 14:17 last edited by
            #19

            @AZEDINE 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:

             self.tabWidgetResult.setTabPosition(QTabWidget.West)
            
            1 Reply Last reply
            0
            • A Offline
              A Offline
              AZEDINE
              wrote on 18 Mar 2025, 14:28 last edited by
              #20

              image.png mon besoin comme ca en python

              J 1 Reply Last reply 18 Mar 2025, 14:38
              0
              • A AZEDINE
                18 Mar 2025, 14:28

                image.png mon besoin comme ca en python

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 18 Mar 2025, 14:38 last edited by
                #21

                @AZEDINE Did you try what @mrjj suggested in this thread?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                A 1 Reply Last reply 19 Mar 2025, 09:11
                0
                • J jsulm
                  18 Mar 2025, 14:38

                  @AZEDINE Did you try what @mrjj suggested in this thread?

                  A Offline
                  A Offline
                  AZEDINE
                  wrote on 19 Mar 2025, 09:11 last edited by
                  #22

                  @jsulm moi utilise python est ce que il ya une solition ???

                  J 1 Reply Last reply 19 Mar 2025, 09:15
                  0
                  • A AZEDINE
                    19 Mar 2025, 09:11

                    @jsulm moi utilise python est ce que il ya une solition ???

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 19 Mar 2025, 09:15 last edited by
                    #23

                    @AZEDINE said in Horizontal text in QTabWidget:

                    moi utilise python est ce que il ya une solition

                    Please use English or post in French sub-forum

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      AZEDINE
                      wrote on 19 Mar 2025, 10:14 last edited by
                      #24
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 19 Mar 2025, 19:41 last edited by
                        #25

                        Hi,

                        Please provide a minimal runnable script that shows your issue.

                        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

                        24/25

                        19 Mar 2025, 10:14

                        • Login

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