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. how to Drag&Drop a file from windows(eg.Window Resource Manager) into QTreeWidget?

how to Drag&Drop a file from windows(eg.Window Resource Manager) into QTreeWidget?

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

    how to Drag&Drop a file from windows(eg.Window Resource Manager) into QTreeWidget?
    when the mouse realease(ie. drop) on a QTreeWidgetItem, the file will added into the related Dir.

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

      Hi,

      Start by having a look at the Drag & Drop documentation

      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
      • O Offline
        O Offline
        opengpu2
        wrote on last edited by
        #3

        i know how to darg beteen widget. but i don't know how can i
        how to Drag&Drop a file from windows(eg.Window Resource Manager) into QTreeWidget?

        J 1 Reply Last reply
        0
        • O opengpu2

          i know how to darg beteen widget. but i don't know how can i
          how to Drag&Drop a file from windows(eg.Window Resource Manager) into QTreeWidget?

          J Offline
          J Offline
          jalomic
          wrote on last edited by
          #4

          @opengpu2 You can find good example "Drop site example" in QtCreator. You know how to read? Read again documentation please:

          Interoperating with Other Applications

          On X11, the public XDND protocol is used, while on Windows Qt uses the OLE standard, and Qt for OS X uses the Cocoa Drag Manager. On X11, XDND uses MIME, so no translation is necessary. The Qt API is the same regardless of the platform. On Windows, MIME-aware applications can communicate by using clipboard format names that are MIME types. Already some Windows applications use MIME naming conventions for their clipboard formats.

          Custom classes for translating proprietary clipboard formats can be registered by reimplementing QWinMime on Windows or QMacPasteboardMime on OS X.

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Start by having a look at the Drag & Drop documentation

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

            @SGaist
            i saw the link, and i found it doesnot use ::strartDrag.
            and as i saw in the Qt examples, i saw ::startDrag is used somewhere.
            which way is better? use the ::startDrag or not(then use ::mousePress,etc...)

            1 Reply Last reply
            0
            • O Offline
              O Offline
              opengpu2
              wrote on last edited by
              #6

              and i noticed: i have to add drag->exec(); int the ::startDrag.
              as i search all the examples, i found drag->exec(); can be in (1)::startDrag, (2)::mousePress, (3)::mouseMove.......what is the different?

              and i found code like this:
              Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
              i don't quite understand the meaning of Qt::DropAction...
              as there can be if (drag->exec(Qt::MoveAction) == Qt::MoveAction) {......}
              what does it mean?

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

                Drop action: you can for example move an item or copy it e.g. move a file from a folder to another. Thus you won't be doing the same things if you are moving something or if you are copying it.

                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
                • O Offline
                  O Offline
                  opengpu2
                  wrote on last edited by
                  #8

                  what should i use , if i just want to pass a QString?
                  should i use Qt::CopyAction ?

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

                    The data contained in the drag object and the action you want to perform based on it are two unrelated things. So it will depend on your application

                    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

                    • Login

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