[vtkusers] Drag and Drop Issues with QVTKWidget

Ben Hughes ben at pixelmachine.org
Mon Mar 12 18:01:29 EDT 2007


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
>
>
>


-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1.2
GAT d--(-) s: a--- C++++ UL++>$ P+ L+++>$ !E W+++$ N+ o? K- w--- O M+
V- PS+(++) PE Y++(+) PGP++ t+ 5 X-- R(+) tv b+(+++) DI+ D++ G e* h! r
!y
-----END GEEK CODE BLOCK-----



More information about the vtkusers mailing list