Hi,

I have an application consisting of a simple QLabel:

Qt Code:
  1. class MyLabel : public QLabel {
  2. Q_OBJECT
  3. public:
  4. MyLabel(QWidget * parent = 0, Qt::WindowFlags f = 0) : QLabel(parent,f) {
  5. setAcceptDrops(true);
  6. setDropIndicatorShown(true);
  7. };
  8.  
  9. virtual ~MyLabel() {};
  10.  
  11. private:
  12. void dragEnterEvent(QDragEnterEvent* event) {
  13. std::cout << "MyLabel::dragEnterEvent()::begin" << std::endl;
  14. event->acceptProposedAction();
  15. std::cout << "MyLabel::dragEnterEvent()::end" << std::endl;
  16. }
  17.  
  18. void dropEvent(QDropEvent* event) {
  19. std::cout << "MyLabel::dropEvent()::begin" << std::endl;
  20. std::cout << "MyLabel::dropEvent()::end" << std::endl;
  21. }
  22. };
To copy to clipboard, switch view to plain text mode 

and a QListView:

Qt Code:
  1. class MyListView : public QListView {
  2. Q_OBJECT
  3. public:
  4. MyListView(QWidget * parent = 0) : QListView(parent) {
  5. setAcceptDrops(true);
  6. setDropIndicatorShown(true);
  7. };
  8.  
  9. virtual ~MyListView() {};
  10.  
  11. private:
  12. void dragEnterEvent(QDragEnterEvent* event) {
  13. std::cout << "MyListView::dragEnterEvent::begin" << std::endl;
  14. event->acceptProposedAction();
  15. std::cout << "MyListView::dragEnterEvent::end" << std::endl;
  16. }
  17.  
  18. void dropEvent(QDropEvent* event) {
  19. std::cout << "MyListView::dropEvent::begin" << std::endl;
  20. std::cout << "MyListView::dropEvent::end" << std::endl;
  21. }
  22. };
To copy to clipboard, switch view to plain text mode 

The QLabel widget accepts drops from files outside the Qt application, resulting in the output:

MyLabel::dragEnterEvent::begin
MyLabel::dragEnterEvent::end
MyLabel::dropEvent::begin
MyLabel::dropEvent::end

The QListview widget does not accept drops from files outside the Qt application, resulting in the output:

MyListView::dragEnterEvent::begin
MyListView::dragEnterEvent::end

So even though the proposed action is accepted in MyListView::dragEnterEvent, the MyListView::dropEvent function is never called...

So my question is the following:

What's keeping the QListView from calling the dropEvent?

Eventually, I will want to add the file names of the dropped files into the list, but without the dropEvent ever being called, I don't see how I can do this...

Cheers,
Ben