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

Add/remove rows will mess up the current selection in a table view.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: P2: Important P2: Important
    • 4.6.0
    • 4.4.0
    • Widgets: Itemviews
    • None

      This was reported on the Qt Jambi interest mailing list and reproduced with 4.4.0 and 4.4 depot build mid august.

      import com.trolltech.qt.gui.*;
      import com.trolltech.qt.core.*;

      public class ItemModel extends QAbstractTableModel {

      public ItemModel()

      { timer = new QTimer(); timer.timeout.connect(this, "addData()"); timer.start(2000); }

      public int rowCount(QModelIndex parent)

      { return rows; }

      public int columnCount(QModelIndex parent)

      { return 4; }

      public Object data(QModelIndex index, int role) {
      if (role == Qt.ItemDataRole.DisplayRole)

      { return "col=" + (index.column() + 1) + ", row=" + (index.row() + 1); }

      return null;
      }

      public void addData() {
      if (decision)

      { beginInsertRows(null, rows - 1, rows - 1); ++rows; endInsertRows(); }

      else

      { beginRemoveRows(null, rows - 1, rows -1); --rows; endRemoveRows(); }

      decision = !decision;
      }

      private int rows = 4;
      private QTimer timer;

      private boolean decision;

      public static void main(String args[])

      { QApplication.initialize(args); QTableView view = new QTableView(); ItemModel model = new ItemModel(); view.setModel(model); view.show(); QApplication.exec(); }

      }

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

            vfm Thierry Bastian (closed Nokia identity) (Inactive)
            sletta Gunnar Sletta
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes