Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Bug in Qt 5.12 drag n'drop ?
Forum Update on Monday, May 27th 2025

Bug in Qt 5.12 drag n'drop ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qat 5.12 drag ndrop
57 Posts 12 Posters 15.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S skylendar

    @mrjj

    On the contrary ! My code didn't change between 5.11 and 5.12, and suddenly it doesn't work...

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #37

    @skylendar said in Bug in Qt 5.12 drag n'drop ?:

    My code didn't change between 5.11 and 5.12, and suddenly it doesn't work

    This does not prove that there is a bug in Qt (though there could be).
    It could be a problem in your code which didn't cause issues with Qt 5.11 but does with Qt 5.12.
    So, before saying there is a bug in Qt you should really prove that.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    A 1 Reply Last reply
    1
    • jsulmJ jsulm

      @skylendar said in Bug in Qt 5.12 drag n'drop ?:

      My code didn't change between 5.11 and 5.12, and suddenly it doesn't work

      This does not prove that there is a bug in Qt (though there could be).
      It could be a problem in your code which didn't cause issues with Qt 5.11 but does with Qt 5.12.
      So, before saying there is a bug in Qt you should really prove that.

      A Offline
      A Offline
      armindev
      wrote on last edited by
      #38

      @jsulm said in Bug in Qt 5.12 drag n'drop ?:

      t prove that there is a bug in

      I also have an Application which has a drag n'drop problem since I've updated to Qt 5.12.0 (macOS 10.14.2 Mojave). The eventFilter method is not called anymore with QEvent::Drop

      Therefore I can not drop anything into my QLineEdit derived object...

      // MyLineEdit is derived from QLineEdit
      
      bool MyLineEdit::eventFilter(QObject* object, QEvent* event)
      {
      
          if(m_droppable) {
      
              if(event->type() == QEvent::DragEnter) {
                  event->accept();
              }
      
              // since Qt 5.12.0 the following condition is never true! 
              if(event->type() == QEvent::Drop) {
                   // this line is never reached
                   // ..
              }
      
          }
      }
      
      
      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by Christian Ehrlicher
        #39

        This works fine with 5.11 and 5.12 on Linux:

        class MyLineEdit : public QLineEdit
        {
            Q_OBJECT
        public:
            using QLineEdit::QLineEdit;
        
            bool eventFilter(QObject *object, QEvent *event)
            {
                if (event->type() == QEvent::DragEnter)
                    event->accept();
                if (event->type() == QEvent::Drop)
                    qDebug() << "Drop";
                return QLineEdit::eventFilter(object, event);
            }
        };
        
        int main(int argc, char *argv[])
        {
            QApplication app(argc, argv);
            MyLineEdit le;
            le.installEventFilter(&le);
            le.show();
            return app.exec();
        }
        
        #include "main.moc"
        

        If it does not work on Mac please open a bug report.

        /edit: There were some dnd changes between 5.11 and 5.12: 10b3286313c78fa380b5fe676a7c14f3ae84f017 - it works fine on Linux, did not yet test on windows and don't have a mac...

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        A 1 Reply Last reply
        2
        • Maaz MominM Offline
          Maaz MominM Offline
          Maaz Momin
          wrote on last edited by
          #40

          Hello guys... Since we are talking about Drag and Drop. Can somebody also look into this bug report?

          https://bugreports.qt.io/browse/QTBUG-70725

          1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            This works fine with 5.11 and 5.12 on Linux:

            class MyLineEdit : public QLineEdit
            {
                Q_OBJECT
            public:
                using QLineEdit::QLineEdit;
            
                bool eventFilter(QObject *object, QEvent *event)
                {
                    if (event->type() == QEvent::DragEnter)
                        event->accept();
                    if (event->type() == QEvent::Drop)
                        qDebug() << "Drop";
                    return QLineEdit::eventFilter(object, event);
                }
            };
            
            int main(int argc, char *argv[])
            {
                QApplication app(argc, argv);
                MyLineEdit le;
                le.installEventFilter(&le);
                le.show();
                return app.exec();
            }
            
            #include "main.moc"
            

            If it does not work on Mac please open a bug report.

            /edit: There were some dnd changes between 5.11 and 5.12: 10b3286313c78fa380b5fe676a7c14f3ae84f017 - it works fine on Linux, did not yet test on windows and don't have a mac...

            A Offline
            A Offline
            armindev
            wrote on last edited by
            #41

            @Christian-Ehrlicher said in Bug in Qt 5.12 drag n'drop ?:

            MyLineEdit

            Hm... this works on mac too!

            Seems to be a special constelation which doesn't work or it's a bug in specific circumstancens only...

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #42

              @armindev said in Bug in Qt 5.12 drag n'drop ?:

              Seems to be a special constelation

              Is it possible to simplify your program until the bug is gone away?

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              A 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                @armindev said in Bug in Qt 5.12 drag n'drop ?:

                Seems to be a special constelation

                Is it possible to simplify your program until the bug is gone away?

                A Offline
                A Offline
                armindev
                wrote on last edited by
                #43

                @Christian-Ehrlicher

                I will try this but this will take a while ..

                1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #44

                  @armindev said in Bug in Qt 5.12 drag n'drop ?:

                  I will try this but this will take a while ..

                  Thx and take your time. There seems to be something wrong in a corner case and it would be really good to find it out :)

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0
                  • S skylendar

                    Hi there and thx for reading and answering if you can.

                    My app based on Qt5 x86_64 worked fine with qt5.11 but suddenly, the drag n'drop doesn't work anymore with qt5.12 ?

                    Have you already noticed this behaviour ? Is this a bug ?

                    Thx again for reading this post.

                    C Offline
                    C Offline
                    cawlfj
                    wrote on last edited by
                    #45

                    @skylendar
                    I found same bug in my app. change to 5.11.2 drop is ok

                    1 Reply Last reply
                    0
                    • SGaistS SGaist

                      "not that different" can be a big can of worm ;)

                      C Offline
                      C Offline
                      cawlfj
                      wrote on last edited by
                      #46

                      @SGaist
                      i found same bug also in my app. change back 5.11 drop come back.
                      windows10 qt5.12.0 QLinedit , can drag from QLineEdit , but can't drop to QLineEdit.
                      Sometimes press the "ctrl" can drop to QLineEdit.

                      1 Reply Last reply
                      0
                      • ModelTechM Offline
                        ModelTechM Offline
                        ModelTech
                        wrote on last edited by
                        #47

                        I have checked the drag & drop in my app when running on Ubuntu 16.04. The drag is from a QListWidgetItem to a drop on a QGraphicsView. I appropriately overrode QGraphicsView::dropEvent (and all the drag methods of QGraphicsView). It still works in Qt5.12.0 although the willingness to accept the QMimeData constructed from the QListWidgetItem as a droppable on the QGraphicsView (visible as a change in the mouse pointer icon) seems to be less than it was with Qt5.7 that I used up to yesterday. No clue whether this is in any way related, but perhaps it brings some ideas of what causes the issue for dropping on a QLineEdit.

                        1 Reply Last reply
                        1
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #48

                          @ModelTech can you provide a minimal compilable example that shows that change of behaviour ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            ReDEnergy
                            wrote on last edited by ReDEnergy
                            #49

                            Hi. I had the same problem. Everything worked fine on Qt 5.7 then after I updated to Qt 5.12 dropping would not work at all.
                            At least in my case it seems that for previous version of Qt only implementing dragEnterEvent was enough but with 5.12 I had to also override the dragMoveEvent event.
                            So, basically I have this 2 things and now it works as expected. Hope it helps someone.

                            void QtDropArea::dragEnterEvent(QDragEnterEvent *event)
                            {
                            	event->acceptProposedAction();
                            }
                            
                            // this was added after updating to Qt 5.12
                            void QtDropArea::dragMoveEvent(QDragMoveEvent *event)
                            {
                            	event->acceptProposedAction();
                            }
                            
                            1 Reply Last reply
                            3
                            • Christian EhrlicherC Offline
                              Christian EhrlicherC Offline
                              Christian Ehrlicher
                              Lifetime Qt Champion
                              wrote on last edited by
                              #50

                              @ReDEnergy said in Bug in Qt 5.12 drag n'drop ?:

                              QtDropArea

                              From what did you derive QtDropArea?

                              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                              Visit the Qt Academy at https://academy.qt.io/catalog

                              1 Reply Last reply
                              0
                              • R Offline
                                R Offline
                                ReDEnergy
                                wrote on last edited by ReDEnergy
                                #51

                                from the classic QWidget

                                1 Reply Last reply
                                0
                                • Christian EhrlicherC Offline
                                  Christian EhrlicherC Offline
                                  Christian Ehrlicher
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #52

                                  Thx for your hint with the dragMoveEvent() reimpl. I think I can reproduce your issue and also found the corresponding commit.

                                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                  Visit the Qt Academy at https://academy.qt.io/catalog

                                  1 Reply Last reply
                                  2
                                  • Christian EhrlicherC Offline
                                    Christian EhrlicherC Offline
                                    Christian Ehrlicher
                                    Lifetime Qt Champion
                                    wrote on last edited by aha_1980
                                    #53

                                    Can you please check if you get a dragEnterEvent in the problematic case? I would guess no.
                                    The problem was introduced with f8944a7f07112c85dc4f66848cabb490514cd28e which is a bugfix for QTBUG-67155.

                                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                    Visit the Qt Academy at https://academy.qt.io/catalog

                                    aha_1980A 1 Reply Last reply
                                    2
                                    • R Offline
                                      R Offline
                                      ReDEnergy
                                      wrote on last edited by
                                      #54

                                      Great to hear that. So, I suppose what I did is a workaround for the moment, but at least it works.

                                      1 Reply Last reply
                                      0
                                      • Christian EhrlicherC Christian Ehrlicher

                                        Can you please check if you get a dragEnterEvent in the problematic case? I would guess no.
                                        The problem was introduced with f8944a7f07112c85dc4f66848cabb490514cd28e which is a bugfix for QTBUG-67155.

                                        aha_1980A Offline
                                        aha_1980A Offline
                                        aha_1980
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #55

                                        @Christian-Ehrlicher I already did some cross-links, can you create a bugreport for that issue?

                                        Qt has to stay free or it will die.

                                        1 Reply Last reply
                                        0
                                        • Christian EhrlicherC Offline
                                          Christian EhrlicherC Offline
                                          Christian Ehrlicher
                                          Lifetime Qt Champion
                                          wrote on last edited by Christian Ehrlicher
                                          #56

                                          https://bugreports.qt.io/browse/QTBUG-72844 and https://codereview.qt-project.org/249086

                                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                          Visit the Qt Academy at https://academy.qt.io/catalog

                                          1 Reply Last reply
                                          3

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved