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. Why call function acceptProposedAction in function dragEnterEvent?
Forum Updated to NodeBB v4.3 + New Features

Why call function acceptProposedAction in function dragEnterEvent?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 444 Views 2 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.
  • Q Offline
    Q Offline
    Quella
    wrote on last edited by
    #1

    Hi everyone!

    Recently I learned how to implement the clipboard function. And I found Qt requires to call acceptProposedAction in the dragEnterEvent in order to trigger function dropEvent.

    I find that when function acceptProposedAction isn't called in function dragEnterEvent, function dropEvent will not be called by debugging the qt source code, but I cannot find the reason.

    I want to know the reason, and the corresponding qt souce code, thanks for your help!

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

      Hi and welcome to devnet,

      There's no reason for the system to process d&d events for a widget that is not concerned. It also allows proper feedback to the user. It's highly annoying when you drop something on a widget that does nothing rather than having an explicit icon saying the operation cannot be done.

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

      Q 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi and welcome to devnet,

        There's no reason for the system to process d&d events for a widget that is not concerned. It also allows proper feedback to the user. It's highly annoying when you drop something on a widget that does nothing rather than having an explicit icon saying the operation cannot be done.

        Q Offline
        Q Offline
        Quella
        wrote on last edited by
        #3

        @SGaist Thanks for your answer!

        Do you know why the system knows that the widget concerns the d&d events after the dragEnterEvent function calls the acceptProposedAction function?

        SGaistS 1 Reply Last reply
        0
        • Q Quella

          @SGaist Thanks for your answer!

          Do you know why the system knows that the widget concerns the d&d events after the dragEnterEvent function calls the acceptProposedAction function?

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          After dragEnterEvent, you have also dragMoveEvent that allows you to control more precisely where on the widget the drop can happen.

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

          Q 1 Reply Last reply
          0
          • Q Quella has marked this topic as solved on
          • SGaistS SGaist

            After dragEnterEvent, you have also dragMoveEvent that allows you to control more precisely where on the widget the drop can happen.

            Q Offline
            Q Offline
            Quella
            wrote on last edited by
            #5

            @SGaist Thanks again! I learn a lot from your answer.

            Actually, at first I want to know if I can debug the souce code to find out the reason. Maybe it involves the underlying mechanism of the windows system, so that I cannot easily find out the reason by debugging the souce code.

            Best regards.

            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