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. Detecting a drop- or drag cancel event outside of my application
Forum Updated to NodeBB v4.3 + New Features

Detecting a drop- or drag cancel event outside of my application

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 391 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.
  • qwasder85Q Offline
    qwasder85Q Offline
    qwasder85
    wrote on last edited by qwasder85
    #1

    I need to detect when an active drag was dropped or cancelled outside of my application. I don't need the mime data or anything about it, just a notice when the current drag is cancelled or dropped outside. Qt doesn't seem to throw any events when this happens.
    Is there a neat way to solve this?

    btw. The exec()-function of the drag object returns "ignored" in any case. Can this be changed somehow to tell me when it was cancelled outside?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      CPPUIX
      wrote on last edited by
      #2

      Hi,

      What about checking cursor position when QDrag object is destroyed?

      Something like this:

      connect(&drag,&QDrag::destroyed,[this]()
      {
         if(!parentWidget()->rect().contains(parentWidget()->mapFromGlobal(QCursor::pos())))
             qDebug()<<"canceled outside";
         else
             qDebug()<<"canceled inside";
      });
      
      qwasder85Q 1 Reply Last reply
      2
      • C CPPUIX

        Hi,

        What about checking cursor position when QDrag object is destroyed?

        Something like this:

        connect(&drag,&QDrag::destroyed,[this]()
        {
           if(!parentWidget()->rect().contains(parentWidget()->mapFromGlobal(QCursor::pos())))
               qDebug()<<"canceled outside";
           else
               qDebug()<<"canceled inside";
        });
        
        qwasder85Q Offline
        qwasder85Q Offline
        qwasder85
        wrote on last edited by qwasder85
        #3

        @Abderrahmene_Rayene That sounds like a good idea, I'll try this.
        Edit: Works like a charm, thank you!

        1 Reply Last reply
        0
        • qwasder85Q qwasder85 has marked this topic as solved on

        • Login

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