Hi,

Is there anything wrong with this code?
It outputs all events the application receives.

I'm trying to get an application to accept drag events that originate from a different application. I noticed that my dragEnterEvent was not being called.

I wrote a minimal application (see below) to test.

The weird thing is I just upgraded from 4.6.1 to 4.6.3 and an application that used to received dragEnterEvent stopped doing so immediately. But I'm not sure right now if that is a co-incidence (I've been changing some code unrelated to DnD).

Here's the minimal project:

Header:

Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5.  
  6. namespace Ui {
  7. class MainWindow;
  8. }
  9.  
  10. class MainWindow : public QMainWindow
  11. {
  12. Q_OBJECT
  13. protected:
  14. bool eventFilter(QObject* o,QEvent* e);
  15. public:
  16. explicit MainWindow(QWidget *parent = 0);
  17. ~MainWindow();
  18.  
  19. private:
  20. Ui::MainWindow *ui;
  21. };
  22.  
  23. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

CPP file:

Qt Code:
  1. #include <QDebug>
  2. #include "mainwindow.h"
  3. #include "ui_mainwindow.h"
  4.  
  5. MainWindow::MainWindow(QWidget *parent) :
  6. QMainWindow(parent),
  7. ui(new Ui::MainWindow)
  8. {
  9. ui->setupUi(this);
  10.  
  11. qApp->installEventFilter(this);
  12. }
  13.  
  14. MainWindow::~MainWindow()
  15. {
  16. delete ui;
  17. }
  18.  
  19. bool MainWindow::eventFilter(QObject* o,QEvent* e)
  20. {
  21. qDebug() << e->type() << o; // e->type is never 60 (QEvent::DragEnter)
  22. if(e->type()==QEvent::DragEnter)
  23. qDebug() << "QEvent::DragEnter"; // THIS IS NEVER OUTPUT
  24. return false;
  25. }
To copy to clipboard, switch view to plain text mode