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

In QTreeWidget item is droped as top level item instead of being inserted between items

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.9
    • 4.7.1, 5.4.0
    • Widgets: Itemviews
    • None
    • Windows

    Description

      When i drag item and drop it between 2 other items it becomes top level insted of beeing inserted where it supposed to. It happens only if VerticalScrollMode is QAbstractItemView::ScrollPerPixel and if item is dropped at red line ( on screenshot).
      I think it can be fixed by editing:
      int QTreeViewPrivate::itemAtCoordinate ( int coordinate) const

      There is if statement:

      if (verticalScrollMode == QAbstractItemView::ScrollPerPixel) {
               if (uniformRowHeights) {
                   const int viewItemIndex = (coordinate + q->verticalScrollBar()->value()) / defaultItemHeight;
                   return (viewItemIndex >= itemCount ? -1 : viewItemIndex);
               }
               // ### optimize
               int viewItemCoordinate = 0;
               const int contentsCoordinate = coordinate + q->verticalScrollBar()->value();
               for (int viewItemIndex = 0; viewItemIndex < viewItems.count(); ++viewItemIndex) {
                   viewItemCoordinate += itemHeight(viewItemIndex);
                   if (viewItemCoordinate >= contentsCoordinate)  //here
                       return (viewItemIndex >= itemCount ? -1 : viewItemIndex);
               }
       }
      

      And line

      if (viewItemCoordinate >= contentsCoordinate) 
      

      should be like

      if (viewItemCoordinate > contentsCoordinate) 
      

      Attachments

        1. main.cpp
          0.7 kB
        2. tree.png
          tree.png
          7 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mmutz Marc Mutz
            pete_sassafras Nikolay S
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes