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

QTableView column resize issue

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.6.1
    • Fix Version/s: 5.9.3
    • Component/s: Widgets: Itemviews
    • Labels:
      None
    • Environment:
      Windows 7 32/64, 10 32/64
    • Commits:
      2937ab9e320ea04fdfda8e3a252559d4762e811e

      Description

      QHeaderView::setCascadingSectionResizes(true) causes problems with interactive resizing of column if it's called for horizontal header of QTableView with hidden columns. Interactive resizing of columns next to hidden looks messed (see attached picture).

      Code to reproduce:

      #include <QApplication>
      
      #include <QMainWindow>
      #include <QVBoxLayout>
      #include <QHeaderView>
      #include <QTableView>
      #include <QAbstractTableModel>
      
      class Model: public QAbstractTableModel {
      public:
          int rowCount(const QModelIndex &) const override {
              return 2;
          }
          int columnCount(const QModelIndex &) const  override {
              return 3;
          }
          QVariant data(const QModelIndex &index, int role) const  override {
              if (!index.isValid())
                  return QVariant();
              if (role = Qt::DisplayRole)
                  return QString("Data");
              return QVariant();
          }
      };
      
      int main(int argc, char *argv[]) {
          QApplication a(argc, argv);
      
          QWidget *pw = new QWidget();
          QVBoxLayout *pl = new QVBoxLayout(pw);
          QTableView *pv = new QTableView(pw);
          pl->addWidget(pv);
      
          pv->setModel(new Model);
          pv->horizontalHeader()->setCascadingSectionResizes(true); // this causes problem
          pv->hideColumn(1);
      
          pw->show();
      
          return a.exec();
      }
      

      Just run and try to resize (expand/shrink) last column.

        Attachments

        1. QTBUG-54601.tar.gz
          1.0 kB
        2. tvb.png
          tvb.png
          3 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            chehrlic Christian Ehrlicher
            Reporter:
            uaf Igor Yampolskiy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes