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

DragDropMode of InternalMove accepts external drops when subclassing QListWidget?

    XMLWordPrintable

Details

    Description

      Reproducer attached. The default behavior of DragDropMode of InternalMove is sort of unexpected.

      The reproducer consists of 2 instances of a QListWdiget subclass. The top one is of InternalMove and the bottom one is DragDrop. The implementation is quite trivial, that the subclass accepts dragEnterEvent and dropEvent unconditionally by default.

      When dragging external objects such as a .txt file from file explorer and trying to drop onto 2 widgets, the behaviors is different. I don't expect such difference since events are overridden, and I expect that DragDropModes does not have any affect.

      DragDrop widget refuses to accept the drop and dropEvent does not happen by default. It is expected since certain MIME types are not yet supported. If the 26th line in 'customlistwidget.cpp' is uncommented so that additional MIME type can be supported, then it accepts the drop. The behavior is as expected.

      InternalMove widget accepts the drop and dropEvent happens regardless of what kind of MIME types are supported by default (whether line 26 is commented or not). Commenting out line 11~13 to explicitly handle InternalMove differently helps it refuse external drop. The behavior here is sort of confusing:
      1. Since events are overridden, I don't expect DragDropModes can affect anything. Yet DragDrop and InternalMove behave differently, that one accepts external drop and the other one refuses by default (without MIME types supported).
      2. It feels like the InternalMove is the 'more wrong' one. It is understandable that if MIME types are not supported, then no dropEvent happens, which is the behavior of DragDrop. On the other hand, behavior of InternalMove is sort of counter-intuitive, that dropEvent happens anyway.

      Is it because that event handling based on DragDropModes is required? So that a minimal trivial implementation with only e->accept() may behave strangely?

      Attachments

        1. QTBUG-114795.tgz
          13 kB
          Axel Spoerl
        2. Reproducer.zip
          8 kB
          Luqiao Chen
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            smd Jan Arve
            luqiaochen Luqiao Chen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes