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

ItemViews - Selection in table views

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P1: Critical P1: Critical
    • 4.6.3
    • 4.6.3
    • Widgets: Itemviews
    • None
    • d6cd6c59dae36b2890baae98f0bf94b23e5509da

      The selection behaviour is different from the one of 4.5.3. The problem is reproduced with the following example.

      • Select multiple rows
      • Click inside the table on one row (of the previous selection)
      • One would expect that only this row is now selected, but it is not. Sometimes it works on the second or third click

      It works always, if you click on the row header instead of inside the table

      #include <QtGui>
      
      class Widget : public QWidget {
          Q_OBJECT
      
      public:
          Widget(QWidget *parent = 0);
      
      private:
          QTableView *view1;
          QStandardItemModel *model;
      };
      
      Widget::Widget(QWidget *parent) : QWidget(parent)
      {
          model = new QStandardItemModel(4, 4);
          for (int row = 0; row < 4; ++row) {
              for (int column = 0; column < 4; ++column) {
                  QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
                  model->setItem(row, column, item);
              }
          }
      
          QHBoxLayout *layout = new QHBoxLayout;
          view1 = new QTableView;
          view1->setModel(model);
          view1->setSelectionBehavior( QAbstractItemView::SelectRows );
          view1->setSelectionMode( QAbstractItemView::ExtendedSelection);
          layout->addWidget(view1);
          setLayout(layout);
      }
      
      
      #include "main.moc"
      
      int main(int argc, char **argv)
      {
          QApplication a(argc, argv);
          Widget w;
          w.resize(1024, 200);
          w.show();
          return a.exec();
      }
      

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

            dedietri Gabriel de Dietrich (drgvond)
            mpejcoch Martin Pejcoch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes