Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
5.9.3
-
None
Description
In the following example, if you open the list, you can drag and drop the items. If you close it and open again, drag and drop no longer works.
The problem is because QWidget code recreates the drop site while the Qt::Window flag is off, invoking QWindowsWindow::updateDropSite, which does the wrong thing and calls setDropSiteEnabled(false).
Related stack overflow thread: https://stackoverflow.com/a/52066150/683905
#include <QtWidgets> int main(int argc, char *argv[]) { QApplication app(argc, argv); QPushButton button("Toggle List"); QListWidget listWidget; button.setMinimumSize(320, 200); Q_ASSERT(!listWidget.testAttribute(Qt::WA_DeleteOnClose)); listWidget.setWindowFlags(Qt::Window | Qt::FramelessWindowHint); listWidget.setDragDropMode(QAbstractItemView::DragDrop); listWidget.setDefaultDropAction(Qt::MoveAction); for (auto s : {"first", "second", "third"}) listWidget.addItem(QLatin1String(s)); QObject::connect(&button, &QPushButton::pressed, [&] { static bool toggle; if ((toggle = !toggle)) { listWidget.setParent(&button, listWidget.windowFlags()); listWidget.show(); } else { listWidget.setParent(nullptr); listWidget.close(); } }); button.show(); return app.exec(); }
Attachments
For Gerrit Dashboard: QTBUG-70240 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
242779,2 | Remove empty function QWidgetPrivate::registerDropSite() | 5.12 | qt/qtbase | Status: MERGED | +2 | 0 |