Search code examples
c++qtdrag-and-drop

Why does drag and drop in Qt stops working?


in our software build in qt 4.8.5 in some cases the drag and drop stops working. There are two places where it should work. One when dragging a file to a certain spot at the application and a second in a QTreeWidget where you can put some leafs into folders.

But on some machines (Windows) both methods just stop working or are not working from the start. Then only a forbidden cursor appears. After a restart of the application drag and drop is working again. It seems not to be a problem with different privileges in windows.

I have no clue where to look for this problem. Any advice is appreciated.


Solution

  • After some days of searching the web I could find the cause of the problem.

    https://bugreports.qt-project.org/browse/qtbug-28601

    In our software you can toggle the size of the module which uses a call to setWindowFlags. After that no more drag and drop events are processed.

    I could workaround the problem by calling:

    setAttribute( Qt::WA_AcceptDrops, false );
    setAttribute( Qt::WA_AcceptDrops, true );
    

    at the widgets which need the drag and drop. Hopefully we're updating to Qt 5.x soon. :/