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

[Regression] Drag and drop text from Qt app into terminal does not work

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.0.0 Beta 1
    • Fix Version/s: 5.0.0 Beta 2
    • Component/s: GUI: Drag and Drop
    • Labels:
      None
    • Environment:
      Ubuntu 12.04, Xcb
    • Commits:
      03fd3a8f34679793b87a5d901202ea2805b89d84

      Description

      1) Run application;
      2) Click inside the applications window to start a drag, drag to termial window.

      Expected: The dragged text appears in terminal window.
      Actual: No changes in a terminal window.

      #include <QtWidgets/QMessageBox>
      #include <QtCore/QDebug>
      #include <QtGui/QDropEvent>
      #include <QtGui/QDrag>
      #include <QtGui/QClipboard>
      #include <QtWidgets/QInputDialog>
      #include <QtWidgets/QLabel>
      #include <QtWidgets/QApplication>
      #include <QtCore/QMimeData>
      #include <QtCore/QBuffer>
      #include <QtGui/QImage>
      #include <QtGui/QPixmap>
      //#include <QtGui>
      //#include <QtCore>
      
      class MyWidget : public QLabel
      {
          Q_OBJECT
      public:
          MyWidget()
              : QLabel(0) {
              setMinimumSize(QSize(200, 200));
              setAcceptDrops(true);
          }
      
      protected:
          virtual void mouseMoveEvent(QMouseEvent*) {
              QDrag* drag = new QDrag(this);
              QMimeData* mimeData = new QMimeData;
      
              mimeData->setText(text());
              drag->setMimeData(mimeData);
              drag->exec();
          }
      
          virtual void dragEnterEvent(QDragEnterEvent* event) {
              //qDebug() << "dragEnterEvent: " << event->proposedAction();
              event->acceptProposedAction();
          }
          virtual void dragMoveEvent(QDragMoveEvent* event) {
              //qDebug() << "dragMoveEvent: " << event->proposedAction();
              event->acceptProposedAction();
          }
      
          virtual void dropEvent(QDropEvent* event) {
              const QMimeData* mimeData = event->mimeData();
      
                  if (mimeData->hasText()) {
                      qWarning("retrieving text");
                      setText("#" + mimeData->text() + " yo");
                  }
      
              qDebug() << "done with data";
              event->acceptProposedAction();
          }
      };
      
      int main( int argc, char ** argv )
      {
          QApplication app(argc, argv);
          qDebug() << "V: " << qVersion();
          MyWidget w1;
          w1.setText("Drag/drop widget");
          w1.show();
      
          return app.exec();
      }
      
      #include "dnd_modaldlg.moc"
      
      

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              paeglis Gatis Paeglis
              Reporter:
              paeglis Gatis Paeglis
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes