[vtkusers] Drag and Drop Issues with QVTKWidget

clinton at elemtech.com clinton at elemtech.com
Mon Mar 12 18:08:48 EDT 2007


Are you are using something like a vtkWin32RenderWindowInteractor instead of 
the QVTKInteractor?
Or are you doing something like vtkRenderWindowInteractor::New() anywhere?  Or 
are you using something like a vtkImageViewer where certain interactor setup 
is required to work with QVTKWidget?

It works for me and others.  Unless I get more info, I don't know why it 
doesn't work for you.

Clint

On Monday 12 March 2007 4:01 pm, Ben Hughes wrote:
> My further investigation indicates that this only works until a
> vtkRenderWindow is added into the mix.  Once the vtkRenderWindow is
> set, all DnD abilities die.  I am looking towards resolutions at this
> time but will probably settle for a Drag n' Drop "dock" type widget
> located below the rendering surface.
>
> Ben Hughes
>
> On 3/12/07, clinton at elemtech.com <clinton at elemtech.com> wrote:
> > > I am attempting to get Drag n' Drop support working for a subclass of
> > > QVTKWidget that I use in a project.  I have reimplemented the
> > > dragEnterEvent() and dropEvent() methods as per Qt instructions.
> > > Nothing happens.  I dropped a qDebug call into the top of both those
> > > methods and can confirm that they are simply not being called.
> > > AcceptDrops is set to true and everything that I can think of is set
> > > up properly?  Has anyone successfully set up DnD with QVTKWidget? If
> > > so, how?
> >
> > It works fine for me in Qt 4.
> >
> > Here's what I did, make myvtkwidget.h in VTK/Examples/GUI/Qt/Events (see
> > header below)
> > Then in the Qt designer promote the QVTKWidgets to MyQVTKWidget.
> > Compile then run the events example.  I dragged something from my desktop
> > and dropped it on one of the MyQVTKWidgets and I got the print outs I
> > expected.
> >
> > Clint
> >
> >
> > ===============================
> > #ifndef MyQVTKWidget_h
> > #define MyQVTKWidget_h
> >
> > #include "QVTKWidget.h"
> > #include <QDragEnterEvent>
> >
> > class MyQVTKWidget : public QVTKWidget
> > {
> > public:
> >   MyQVTKWidget(QWidget* p) : QVTKWidget(p)
> >     {
> >     this->setAcceptDrops(true);
> >     }
> > protected:
> >   void dragEnterEvent(QDragEnterEvent* e)
> >     {
> >     printf("got drag enter event %i\n", this->acceptDrops());
> >     e->acceptProposedAction();
> >     }
> >   void dropEvent(QDropEvent* e)
> >     {
> >     printf("got drop event\n");
> >     }
> > };
> >
> > #endif //  MyQVTKWidget_h



More information about the vtkusers mailing list