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

QTabWidget::setTabText is making the current Tab visible.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Cannot Reproduce
    • Affects Version/s: 4.7.4, 4.8.2
    • Fix Version/s: None
    • Component/s: GUI: Look'n'Feel
    • Labels:
      None

      Description

      QTabWidget::setTabText method is making the current Tab visible ( Calling QTabBarPrivate::refresh that itself call QTabBarPrivate::makeVisible ).

      This behavior should be optional and most likely deactivated by default.

      For instance, I'm using the QTabWidget to host various code editors, each time a modification is done in an editor, I modify the Tab title to signify the dirty unsaved state ( Appending "*" that get removed when I save the file ).
      As a result the QTabBar is scrolling the tabs, which is very very annoying and impractical. You wouldn't code in an IDE or Text Editor doing that.

      I have not found a way to change this behavior ( Except by not modifying the Tab text ), and to make things worse, the current Tab is scrolled to the extreme right and not in the middle of the QTabBar.

      Here is a Python example:

      First try scrolling on the right, and hit one of the two buttons, then set the current Tab to either 16 or 24 and hit the matching button.

      import sys
      from PyQt4 import QtGui
      
      class Ui(QtGui.QWidget):
      
      	def __init__(self):
      		super(Ui, self).__init__()
      
      		tabWidget = QtGui.QTabWidget()
      		tabWidget.setMovable(True)
      		tabWidget.setUsesScrollButtons(True)
      		for i in range(32):
      			tabWidget.addTab(QtGui.QWidget(), "Tab {0}".format(i))
      
      		gridLayout = QtGui.QGridLayout()
      		gridLayout.addWidget(tabWidget)
      
      		buttonA = QtGui.QPushButton("Set Tab 16 Title")
      		buttonA.clicked.connect(lambda x: tabWidget.setTabText(16, "Tab 16 *"))
      		buttonB = QtGui.QPushButton("Set Tab 24 Title")
      		buttonB.clicked.connect(lambda x: tabWidget.setTabText(24, "Tab 24 *"))
      		gridLayout.addWidget(buttonA)
      		gridLayout.addWidget(buttonB)
      
      		self.setLayout(gridLayout)
      
      		self.resize(600, 300)
      
      app = QtGui.QApplication(sys.argv)
      ui = Ui()
      ui.show()
      sys.exit(app.exec_())
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            chehrlic Christian Ehrlicher
            Reporter:
            kelsolaar Thomas Mansencal
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes