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

QHeaderView::initializeSections unhides hidden columns if the section count is changed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4: Low
    • None
    • 4.8.0, 5.0.0
    • Widgets: Itemviews
    • None

    Description

      #include <QTableView>
      #include <QHeaderView>
      #include <QApplication>
      #include <QStandardItemModel>
      #include <QDateTime>
      #include <QTimer>
      
      class Model : public QStandardItemModel
      {
          Q_OBJECT
      public:
          Model(const QStringList &list, QObject *parent = 0)
            : QStandardItemModel(parent)
          {
              foreach(const QString &s, list) {
                  QStandardItem *item = new QStandardItem(s);
                  appendRow(item);
              }
              for (int i =0; i < list.size(); ++i)
                  setVerticalHeaderItem(i, new QStandardItem("SEC" + QString::number(i)));
              QTimer::singleShot(2000, this, SLOT(deleteRow()));
          }
      
      private slots:
          void deleteRow()
          {
              layoutAboutToBeChanged();
              blockSignals(true);
      
              removeRow(1);
      
              blockSignals(false);
              layoutChanged();
          }
      };
      
      int main( int argc, char **argv)
      {
        QApplication app(argc, argv);
      
        QTableView view;
        view.setSortingEnabled(true);
      
        Model model(QStringList() << "Monday" << "Tuesday" << "Wednesday" << "Thursday" << "Friday" << "Saturday" << "Sunday");
      
        view.resize(400, 400);
        view.show();
      
        view.setModel(&model);
      
        view.verticalHeader()->hideSection(1);
        view.verticalHeader()->hideSection(2);
      
        return app.exec();
      }
      
      #include "main.moc"
      

      This is related to http://codereview.qt-project.org/#change,19149

      Attachments

        Issue Links

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

          Activity

            People

              richard Richard Moe Gustavsen
              stephen.kelly Stephen Kelly (Unused account) (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes