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. [SOLVED] Drag 'n drop a file in an editor: different behaviour on Linux compared to Windows / Mac OS X
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Drag 'n drop a file in an editor: different behaviour on Linux compared to Windows / Mac OS X

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.9k Views 1 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.
  • A Offline
    A Offline
    agarny
    wrote on last edited by
    #1

    Hi,

    My application has an editor and supports drag and drop. (I use QScintilla for my editor, but the problem occurs with QTextEdit, so it doesn't seem to be widget dependent.)

    Now, if I select some text (from another application), drag it and drop it on my application's editor, then the text gets inserted (as expected). However, if I select some files (from a file manager of sorts), drag them and drop them on my application's editor, then on Windows and Mac OS X, the dropping of the files gets handled by my application (which opens the files in its editor) while on Linux, the dropping of the files results in their URL being inserted (e.g. file:///home/me/myFile).

    So, how come the behaviour on Linux is different from that on Windows and Mac OS X? Anyone, any idea?

    Cheers, Alan.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      That would depend on the implementation of your drop methods as well as on the contentes of the drag itself. Did you have a look what's inside the drag with the dropsite example from the sources?

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • A Offline
        A Offline
        agarny
        wrote on last edited by
        #3

        Yes, I had checked the format of the dropped data and indeed on Windows/Mac OS X, the data had a text/uri-list format while on Linux it also had text/plain format.

        Anyway, for some reason, your message made me think of dragEnterEvent and testing the format of the data there, and decide whether to accept the event or not. In other words, I have created a new class which inherits from QsciScintilla and which overrides dragEnterEvent:

        @void QScintilla::dragEnterEvent(QDragEnterEvent *pEvent)
        {
        if (!pEvent->mimeData()->hasFormat("text/uri-list"))
        pEvent->acceptProposedAction();
        else
        pEvent->ignore();
        }@

        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