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

Don't show accept-cursor when QDragEnterEvent is accepted, but a QDragMoveEvent does not accept the position

    XMLWordPrintable

Details

    Description

      The following QTreeView subclass demonstrates the issue:

      class TreeView : public QTreeView
      {
      public:
      TreeView()

      { setAcceptDrops(true); }

      protected:
      void dragEnterEvent(QDragEnterEvent *e)

      { qDebug() << "Enter" << e->pos(); e->accept(); }

      void dragMoveEvent(QDragMoveEvent *e)

      { qDebug() << "Move" << e->pos(); checkEvent(e); }

      private:
      void checkEvent(QDropEvent *e)

      { e->ignore(); QModelIndex index = indexAt(e->pos()); if (!index.isValid()) return; if (!index.parent().isValid()) e->accept(); }

      };

      When dragging anything into the widget at a point where there is not a top-level item, then the cursor shows an accepted state for the very first pixel, and then with the next mouse move updates the cursor. Since a drop at that point would fail this is misleading to the user.

      Not accepting the QDragEnterEvent at that point (i.e. call checkEvent from that event handler as well) makes Qt never deliver any QDragMoveEvents anymore (as the QDragManager's current target is not set in QApplication::notify).

      Attachments

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

        Activity

          People

            sorvig Morten Sørvig
            vhilshei Volker Hilsheimer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes