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

[regression from qt4] QDragEnterEvent without QDragMoveEvent

    XMLWordPrintable

Details

    Description

      The documentation says "The drag enter event is always immediately followed by a drag move event" but there are no QDragMoveEvent event on move mouse from a child widget to a parent. Please see the screencast and the example.

      #include <iostream>
      #include <QtWidgets>
      
      struct my_widget : QWidget {
          my_widget() {
              setAcceptDrops( true );
      
              const auto te = new QTextEdit( this );
      
              const auto bl = new QHBoxLayout;
              bl->addSpacing( 20 );
              bl->addWidget( te, 1 );
      
              setLayout( bl );
          }
      
          void dragEnterEvent( QDragEnterEvent* e ) override {
              std::cout << "ENTER: x = " << e->pos().x() << ", y = " << e->pos().y() << std::endl;
              e->accept();
          }
      
          void dragLeaveEvent( QDragLeaveEvent* e ) override {
              std::cout << "LEAVE" << std::endl;
              e->accept();
          }
      
          void dragMoveEvent( QDragMoveEvent* e ) override {
              std::cout << "MOVE: x = " << e->pos().x() << ", y = " << e->pos().y() << std::endl;
              e->acceptProposedAction();
          }
      
          void dropEvent( QDropEvent* e ) override {
              std::cout << "DROP: x = " << e->pos().x() << ", y = " << e->pos().y() << std::endl;
              e->accept();
          }
      };
      
      int main( int argc, char** argv ) {
          QApplication a( argc, argv );
      
          my_widget w;
          w.show();
      
          return a.exec();
      }
      
      ENTER: x = 31, y = 53
      DROP: x = 31, y = 53
      

      The screencast also uploaded to https://www.youtube.com/watch?v=cMYA3B2mxV0

      Attachments

        1. main.cpp
          1 kB
        2. qtcreator.mp4
          247 kB
        3. qtcreator2.mp4
          1.71 MB
        4. qtdrop.mp4
          867 kB

        Issue Links

          Activity

            People

              paeglis Gatis Paeglis
              igornikitin Igor
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: