Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.1.1
-
None
-
OSX 10.8
-
-
fcabeb2e4758b2d39cfc82928a22f8afdf27ba50
Description
Qt 5 broke the drop cursors on Mac.
Run the following code example against Qt 4.8.4 and Qt 5.1.1. It creates a single widget with two drop zones (QLineEdits); one accepts drags from the push button, one does not.
#include <QApplication> #include <QPushButton> #include <QLineEdit> #include <QDrag> #include <QMimeData> #include <QHBoxLayout> #include <QDragEnterEvent> struct AcceptWidget : public QLineEdit { AcceptWidget(QWidget *parent = 0) : QLineEdit(parent) { setAcceptDrops(true); setReadOnly(true); setText("<accepts drops>"); } void dragEnterEvent(QDragEnterEvent *evt) { // BUG: Displays accept/copy cursor in Qt 4.8.x, but only intermittently in Qt 5.1.x evt->acceptProposedAction(); } void dropEvent(QDropEvent *evt) { setText(evt->mimeData()->text().toUtf8().data()); } }; struct DeclineWidget : public QLineEdit { DeclineWidget(QWidget *parent = 0) : QLineEdit(parent) { setReadOnly(true); setText("<declines drops>"); } void dragEnterEvent(QDragEnterEvent *evt) { // BUG: Displays forbidden cursor in Qt 4.8.x, but nothing in Qt 5.1.x evt->ignore(); } }; struct DragWidget : public QWidget { Q_OBJECT public: DragWidget(QWidget *parent = 0) : QWidget(parent) { setWindowTitle("Drag Widget"); setMinimumSize(400, 100); QHBoxLayout *layout = new QHBoxLayout(this); QPushButton *pushButton = new QPushButton("Click Me", this); layout->addWidget(pushButton); AcceptWidget *acceptWidget = new AcceptWidget(this); layout->addWidget(acceptWidget); DeclineWidget *declineWidget = new DeclineWidget(this); layout->addWidget(declineWidget); connect(pushButton, SIGNAL(pressed()), this, SLOT(startDrag())); } private Q_SLOTS: void startDrag() { QDrag *dr = new QDrag(this); QMimeData *data = new QMimeData; data->setText("This is a test"); dr->setMimeData(data); dr->exec(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction, Qt::MoveAction); } }; #include "main.moc" int main(int argc, char **argv) { QApplication a(argc, argv); DragWidget dragWidget; dragWidget.show(); return a.exec(); }
Qt 4.8.4
- The forbidden cursor is displayed for declined drags.
- The copy cursor is displayed for the accepted copy action.
- The link cursor is displayed for the accepted link action.
- The mime text is displayed for the accepted move action.
Qt 5.1.1
- The forbidden cursor is never displayed.
- The copy cursor is displayed for the accepted copy action but only intermittently (it doesn't toggle on and off with the modifier).
- The link cursor is never displayed.
- The mime text is never displayed
- In all cases, a small box is draw next the cursor (wrong).
All regressions in Qt 5.