Qt World Summit: Register Today!

DragLeaveEvent wont be called

  • Hello Guys,
    I've got go a question that's annoying me for a few days...

    I wrote a program in which you can drag&drop an element to another. The DragEnterEvent and the DragMoveEvent were called correctly but the DragLeaveEvent isn't called but as soon as I drop the "package" or leave the form with my cursor it is called instantly.

    I got no plan why this is doing this way hope you can help me with this!

    Greets Marcel

  • Lifetime Qt Champion

    Hi and welcome
    This event handler is called when a drag is in progress and the mouse leaves this widget

    But if your widget is the whole form, it would only send this if you move the mouse outside
    the form.

    If you had a widget inside the form, moving outside this widget should fire it.

  • Yeah mrjj,

    Here's the code to add the widget to the screen:

    RootItem* rootItem = new RootItem();

    I tought this would "add" the widget, cause when I enter this widget the event is triggered correctly...

    Here you can see the form: http://files.classy-gaming.de/editor.png
    This element should be colored white as I leave it with the cursor but it doesn't.

  • Lifetime Qt Champion

    so rootItem is your "drop" widget?
    Is the yellow on picture rootitem or the white one where mouse is? ( A=8 )

    It does look correct so a bit odd.

    void dragEnterEvent(QDragEnterEvent* event) Q_DECL_OVERRIDE;

    should be called when u leave this small area.

    I assume you are 100% sure that is not called and its not just
    the change to while part that is failing.

    I can't guess from this little code what could be wrong.sorry.

    Just for test, could you run my editor and see it does indeed say
    "drag leave" when u drag from the list on the left to center.