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

QTreeView : Drag operations becomes a select.

    XMLWordPrintable

Details

    Description

      Inconsistent behavior can be observed when dragging items around a QTreeView. When the pointer is exactly between items instead of selecting one item in a drag operation the drag becomes a select.

      This can be seen with the following behavior.

      Start the example application below and with no modifier keys down click and hold the mouse between two items.

      One of the items gets selected. Then with the mouse still down drag away from the selected one. For instance straight up if row8 got
      selected.

      If the mouse pointer is located in the narrow spot between items instead of dragging the item that is selected a selection drag is performed.

      #include <QtGui/QtGui>
      int main(int argc, char **argv)
      {
      QApplication app(argc, argv);
      QTreeView* view = new QTreeView(0);
      view -> setSelectionMode(QAbstractItemView::ExtendedSelection);
      view -> setDragDropMode(QAbstractItemView::DragDrop);
      view -> setDragEnabled(true);

      QStandardItemModel *model = new QStandardItemModel(8,1,0);
      for (int row = 0; row < 8; row++)

      { QModelIndex index = model->index(row, 0); model->setData(index, QVariant(QString("row %0").arg(row+1))); }

      view->setModel(model);
      view->show();
      return app.exec();
      }

      Attachments

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

        Activity

          People

            monsen Marius Bugge Monsen
            dettman Dean Dettman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes