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

Drag accept cursor is very ugly on Windows

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.4.0
    • 5.1.0
    • GUI: Look'n'Feel
    • None
    • Windows 7
    • 7de95ede1bc542c329bf1d23633615693a04d14e 6577ac381e73b2ce3d57d2e8a39edb424ce9a52d

    Description

      Qt5 broke the drop accept cursor on Windows. This is similar to QTBUG-33824 on Mac.

      Run the following code example against Qt 4.8.4 and Qt 5.1.0. 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 ugly black cursor in Qt 5.1.x
              evt->acceptProposedAction();
          }
      
          void dragMoveEvent(QDragMoveEvent *evt)
          {
              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)
          {
              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::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 accept cursor is white arrow, as expected.

      Qt 5.1.1

      • The accept cursor is an ugly black, stretched cursor.

      Regression in Qt 5. This is severely impacting our product.

      I tried to create screenshots but Windows is apparently incapable of capturing the screen with the mouse cursor. Just run the example and compare the results.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            portale Alessandro Portale
            danny77uk Daniel
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes