Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-33824

Drag drop cursors are broken on Mac

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.1.1
    • Fix Version/s: 5.5.0 Beta
    • Labels:
      None
    • Environment:
      OSX 10.8
    • Platform/s:
      macOS
    • Commits:
      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.

        Attachments

        1. Qt484AcceptCopy.png
          Qt484AcceptCopy.png
          26 kB
        2. Qt484AcceptLink.png
          Qt484AcceptLink.png
          25 kB
        3. Qt484AcceptMove.png
          Qt484AcceptMove.png
          25 kB
        4. Qt484Decline.png
          Qt484Decline.png
          26 kB
        5. Qt511AcceptCopy.png
          Qt511AcceptCopy.png
          25 kB
        6. Qt511AcceptMove.png
          Qt511AcceptMove.png
          24 kB
        7. Qt511Decline.png
          Qt511Decline.png
          23 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              filipe.azevedo Filipe Azevedo
              Reporter:
              danny77uk Daniel
            • Votes:
              7 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes