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

QTableView incorrect alternating row color for spanned rows when hiding row above

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • Some future release
    • 4.5.2
    • Widgets: Itemviews
    • None
    • GNU/Linux Fedora release 8 (Werewolf)

    Description

      For a QTableView with the alternatingRowColors property enabled, hiding a row causes all spanned rows below it be painted with an incorrect background color. This example demonstrates the problem:

      #include <QtGui>
      #include <QtCore>
      
      class MyWidget : public QWidget
      {
      Q_OBJECT
      public:
      	MyWidget(QWidget *parent=0) : QWidget(parent) {
      		model = new QStandardItemModel(10, 5, this);
      		for (int row = 0; row < 10; row++) {
      			for (int col = 0; col < 5; col++) {
      				QStandardItem *item = new QStandardItem(QString("row %0, col %1").arg(row).arg(col));
      				model->setItem(row, col, item);
      			}
      		}
      		view = new QTableView(this);
      		view->setAlternatingRowColors(true);
      		view->setModel(model);
      		view->setSpan(7, 0, 1, 5);
      	
      		button = new QPushButton("Hide 3rd row", this);
      		connect(button, SIGNAL(clicked()), this, SLOT(hideRow()));
      	
      		layout = new QVBoxLayout(this);
      		layout->addWidget(view);
      		layout->addWidget(button);
      	}
      
      public slots:
      	void hideRow() { view->setRowHidden(2, true); }
      
      private:
      	QTableView *view;
      	QStandardItemModel *model;
      	QPushButton *button;
      	QVBoxLayout *layout;
      };
      
      int main(int argc, char *argv[]) {
          QApplication a(argc, argv);
          MyWidget w;
          w.resize(600,400);
          w.show();
          return a.exec();
      }
      

      Attachments

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

        Activity

          People

            dedietri Gabriel de Dietrich (drgvond)
            jugdish Jugdish
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes