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

Bug in QHeaderView with setTextElideMode(Qt::ElideRight)

    XMLWordPrintable

Details

    Description

      QHeaderView will decide to elide the text based on whether or not there is room to display the text using the default font but most styles use a bold font for the current section. This way the eliding doesn't happen when it should. Shouldn't the style do the eliding since it is the one that knows what font to use?

      To reproduce:

      run this app
      click on a header section
      notice how the text is truncated off the left edge but not elided

      #include <QtGui>

      class TableModel : public QAbstractTableModel
      {
      public:
      TableModel()
      {
      }

      QVariant data(const QModelIndex &, int) const

      { return QVariant(); }

      QVariant headerData(int , Qt::Orientation o, int role) const

      { if (role == Qt::DisplayRole && o == Qt::Horizontal) return " very long string is so long it will never fit correctly"; else return QVariant(); }

      int rowCount(const QModelIndex &) const

      { return 2; }

      int columnCount(const QModelIndex &) const
      { return 2; }

      };

      int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);

      QTableView *tv = new QTableView();
      tv->horizontalHeader()->setTextElideMode(Qt::ElideRight);
      tv->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
      tv->verticalHeader()->hide();
      tv->setModel(new TableModel());
      tv->show();

      return a.exec();
      }

      Attachments

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

        Activity

          People

            bjnilsen Bjørn Erik Nilsen
            rve Anders Bakken
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes