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

QTabBar incorrectly shows scroll buttons when eliding is enabled

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 4.8.2
    • GUI: Look'n'Feel
    • None
    • Windows 7

    Description

      If I subclass QTabBar and set elideMode to something other than ElideNone, the widget has the potential to display scroll buttons when they are not needed.

      See the attached image and project.

      This seems to boil down to a change where eliding was made more aggressive in QTabBar: http://qt.gitorious.org/qt/qt/merge_requests/583

      For a short tab name, like "Main" (which is narrower than "M...n"), minimumTabSizeHint() will return an incorrect value.

      I have fixed this locally by changing that method to this:

      QSize QTabBarPrivate::minimumTabSizeHint(int index)
      {
          Q_Q(QTabBar);
          // ### Qt 5: make this a protected virtual function in QTabBar
          Tab &tab = tabList[index];
      
          const QFontMetrics fm = q->fontMetrics();
      
          QString oldText = tab.text;
          QString elidedText = computeElidedText(elideMode, oldText);
      
          if(fm.size(Qt::TextShowMnemonic, elidedText).width() < fm.size(Qt::TextShowMnemonic, oldText).width())
          {
             tab.text = elidedText;
             QSize elidedSize = q->tabSizeHint(index);
             tab.text = oldText;
             return elidedSize;
          }
      
          return q->tabSizeHint(index);
      }
      

      Attachments

        1. badtabbuttons.png
          badtabbuttons.png
          14 kB
        2. tabtest.zip
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            owen@safe.com Owen Gibbins
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes