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. Drag & Drop to external application(eg. drag from Qt app to Windows desktop/explorer)?
Qt 6.11 is out! See what's new in the release blog

Drag & Drop to external application(eg. drag from Qt app to Windows desktop/explorer)?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.8k Views 3 Watching
  • 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.
  • O Offline
    O Offline
    opengpu2
    wrote on last edited by
    #1

    Drag & Drop to external application(eg. drag from Qt app to Windows desktop/explorer)?
    i want to drag QTreeWidgetItem from my Qt app to Windows desktop/explorer, after i drop, i want to copy the file which the QTreeWidgetItem represents to the destination path of Windows desktop/explorer.
    thank you

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

      Hi,

      Why did you delete this thread just to ask the same question again ?

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

      O 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Why did you delete this thread just to ask the same question again ?

        O Offline
        O Offline
        opengpu2
        wrote on last edited by
        #3

        @SGaist i think ask like this is better:D
        thank you!
        and do you know how to do this?

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

          Then please, edit your original post and rephrase it, what you are doing there is just creating noise and if somebody had replied you would also generate unneeded fragmentation.

          With pure Qt API ? No, I don't know, but since it's something Windows specific you should look at the native API for that part.

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

          O 1 Reply Last reply
          0
          • SGaistS SGaist

            Then please, edit your original post and rephrase it, what you are doing there is just creating noise and if somebody had replied you would also generate unneeded fragmentation.

            With pure Qt API ? No, I don't know, but since it's something Windows specific you should look at the native API for that part.

            O Offline
            O Offline
            opengpu2
            wrote on last edited by
            #5

            @SGaist but i startDarg in Qt app, and drop in Windows explorer...

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              Hi
              To drag to explorer from Qt there must be a real file. In memory did not work for me.
              This drags a Temp file to the desktop/explorer. (in win 7)

              #include <QtGui>
              #include <QLabel>
              class Label : public QLabel {
               protected:
                void mouseMoveEvent(QMouseEvent* event) {
                  QTemporaryFile file;
                  if (file.open()) {
                    QUrl url = QUrl::fromLocalFile(file.fileName());
                    file.write(text().toUtf8());
                    file.close();
              
                    QDrag* drag = new QDrag(this);
                    QMimeData* mimeData = new QMimeData;
                    mimeData->setUrls(QList<QUrl>() << url);
                    drag->setMimeData(mimeData);
                    drag->exec(Qt::CopyAction);
                  }
                }
              };
              
              int main(int argc, char* argv[]) {
                QApplication app(argc, argv);
                Label label;
                label.setText("DRAG HERE");
                label.show();
                return app.exec();
              }
              
              1 Reply Last reply
              0

              • Login

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