Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-12697

QTabBar rect wrong size and wrong qss style

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4: Low P4: Low
    • Some future release
    • 4.6.3, 5.0.0
    • None
    • Linux, X11, KDE4.4 + Qt 4.6.3 + NVidia GT8600GTS

      When documentMode of QTabWidget is set to False, rect of QTabBar will have the size of the sum of all tabs width, but this doesn't mean the size of the QTabWidget. Moving the tabs will result in a cut effect because of the rect. If QTabBar is subclassed and forced to do the rect with QTabWidget width, it will just ignore the alignment set with qss. Here you have an example code:

      # -*- coding: utf-8 -*-
      from PyQt4.QtCore import QSize
      from PyQt4.QtGui import *
      
      class TabBar(QTabBar):
        def __init__(self, parent=None):
          QTabBar.__init__(self, parent)
          self.parent = parent
          self.cw = self.width()
          self.ch = self.height()
      
        def sizeHint(self):
          w = self.parent.width()
          return QSize(w, self.ch)
      
        def tabSizeHinta(self, index):
          w = self.width() / self.count()
          return QSize(w, self.ch)
      
      app = QApplication([])
      
      tabwidget = QTabWidget()
      tabwidget.setMovable(True)
      tabBar = TabBar(tabwidget)
      tabwidget.setTabBar(tabBar) #Uncomment this line to see the "cut" bug.
      tabwidget.insertTab(0, QTextEdit(), "test")
      tabwidget.insertTab(1, QTextEdit(), "test1")
      tabwidget.setMovable(True)
      tabwidget.setStyleSheet("QTabWidget {qproperty-tabPosition: South;} QTabWidget::tab-bar {subcontrol-position: center;} ") #If setTabBar is commented, this will center tabs
      
      tabwidget.show()
      app.exec_()
      

        1. qtbug12697.zip
          2 kB
        2. tab_cut.png
          tab_cut.png
          2 kB
        3. untitled5.zip
          3 kB
        For Gerrit Dashboard: QTBUG-12697
        # Subject Branch Project Status CR V

            Unassigned Unassigned
            alexandernst Alexander Nestorov
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes