Drag and drop in custom application does not work

Hi,

I built ParaView from the master branch, then used this ParaView to build the SimpleParaView example application. Drag & drop a file to the render window works in ParaView that I built, but not in the custom application. Was drag & drop deactivated on purpose in the SimpleParaViewI?

In ParaView/ParaViewMainWindow.cxx there is this code:

//-----------------------------------------------------------------------------
void ParaViewMainWindow::dragEnterEvent(QDragEnterEvent* evt)
{
  pqApplicationCore::instance()->getMainWindowEventManager()->dragEnterEvent(evt);
}

//-----------------------------------------------------------------------------
void ParaViewMainWindow::dropEvent(QDropEvent* evt)
{
  pqApplicationCore::instance()->getMainWindowEventManager()->dropEvent(evt);
}

And also the following in ParaView/ParaViewMainWindow.ui

  <property name="acceptDrops">
   <bool>true</bool>
  </property>

Which is not present in SimpleParaView

Thank you. Does it need modification in the build system? Adding these (along with the declarations in the header file) was not enough:

/home/zc/paraview/Examples/CustomApplications/SimpleParaView/client/myMainWindow.cxx: In member function ‘virtual void myMainWindow::dragEnterEvent(QDragEnterEvent*)’:
/home/zc/paraview/Examples/CustomApplications/SimpleParaView/client/myMainWindow.cxx:88:61: error: invalid use of incomplete type ‘class pqMainWindowEventManager’
   88 |   pqApplicationCore::instance()->getMainWindowEventManager()->dragEnterEvent(evt);
      |                                                             ^~
In file included from /home/zc/paraview/Examples/CustomApplications/SimpleParaView/client/myMainWindow.cxx:7:
/home/zc/paraview_install/include/paraview-6.0/pqApplicationCore.h:17:7: note: forward declaration of ‘class pqMainWindowEventManager’
   17 | class pqMainWindowEventManager;
      |       ^~~~~~~~~~~~~~~~~~~~~~~~
/home/zc/paraview/Examples/CustomApplications/SimpleParaView/client/myMainWindow.cxx: In member function ‘virtual void myMainWindow::dropEvent(QDropEvent*)’:
/home/zc/paraview/Examples/CustomApplications/SimpleParaView/client/myMainWindow.cxx:94:61: error: invalid use of incomplete type ‘class pqMainWindowEventManager’
   94 |   pqApplicationCore::instance()->getMainWindowEventManager()->dropEvent(evt);
      |                                                             ^~
/home/zc/paraview_install/include/paraview-6.0/pqApplicationCore.h:17:7: note: forward declaration of ‘class pqMainWindowEventManager’
   17 | class pqMainWindowEventManager;
      |       ^~~~~~~~~~~~~~~~~~~~~~~~

Probably an include ?

I included

#include <QDragEnterEvent>
#include <QDropEvent> 

so it shouldn’t be the problem. By the way, Clients/ParaView/ParaViewMainWindow.cxx only includes QDragEnterEvent, so QDropEvent must be included implicitly.

#include "pqMainWindowEventManager.h"

Sorry, my bad. It works now.

1 Like