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. Generating mousePress event for drag event
QtWS25 Last Chance

Generating mousePress event for drag event

Scheduled Pinned Locked Moved Unsolved General and Desktop
qdragmouse eventgenerate event
6 Posts 3 Posters 2.2k 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.
  • J Offline
    J Offline
    Joel Bodenmann
    wrote on 23 Jul 2016, 14:06 last edited by
    #1

    Hello folks,

    I have drag-n-drop working in my custom QWidget subclass. Everything is working fine so far. The user can drag-n-drop items around similar to the fridge magnets example.
    Now, what I added is a Duplicate option to the custom context menu of the item. That menu entry (action) just calls a slot in which I generate and execute the QDrag exactly the same as I would do in my mouseMoveEvent() function. That works too, the drag gets executed properly. The problem I have is that the slot is being called when the user releases the mouse button after he pressed it down on the Duplicate menu entry in the context menu. The release of the mouse button causes the slot to be executed. The drag is created but the item is dropped immediately because the mouse button is not held down. Therefore, the user doesn't get a change to position the item with his mouse before manually dropping it. Instead, the duplicated item is dropped exactly where the Duplicate context menu entry has been clicked.

    Is there any way around this? Ideally I'd like to archive the behavior that the user clicks the Duplicate context menu entry, then moves the mouse around to position the item and then clicks to drop it.

    I tried several things including executing qApp->processEvents() before the slot is called. Without luck.

    Industrial process automation software: https://simulton.com
    Embedded Graphics & GUI library: https://ugfx.io

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 23 Jul 2016, 22:25 last edited by
      #2

      Hi,

      Maybe not a direct answer however I'm rather used that when I ask for a duplicate on a graphic editing program, the duplicated object gets placed on the screen slightly displaced regarding the original object. Then you can grab it at will.

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

      J 1 Reply Last reply 25 Jul 2016, 08:53
      3
      • S SGaist
        23 Jul 2016, 22:25

        Hi,

        Maybe not a direct answer however I'm rather used that when I ask for a duplicate on a graphic editing program, the duplicated object gets placed on the screen slightly displaced regarding the original object. Then you can grab it at will.

        J Offline
        J Offline
        Joel Bodenmann
        wrote on 25 Jul 2016, 08:53 last edited by
        #3

        Thank you for your suggestion. I ended up implementing the behavior that you described to have something that works as expected.

        Industrial process automation software: https://simulton.com
        Embedded Graphics & GUI library: https://ugfx.io

        M 1 Reply Last reply 25 Jul 2016, 09:20
        1
        • J Joel Bodenmann
          25 Jul 2016, 08:53

          Thank you for your suggestion. I ended up implementing the behavior that you described to have something that works as expected.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 25 Jul 2016, 09:20 last edited by
          #4

          @Joel-Bodenmann

          I can only second that. I use many drawing programs and those who has clone, all offset
          the clone and then u must then drag it.

          Having it stick to the mouse after you release it, would be confusing. :)

          1 Reply Last reply
          2
          • J Offline
            J Offline
            Joel Bodenmann
            wrote on 25 Jul 2016, 09:41 last edited by
            #5

            Thank you for your comment! Apparently the proper fix to this problem is me stopping to have weird-behavior expectations of my software :p

            Industrial process automation software: https://simulton.com
            Embedded Graphics & GUI library: https://ugfx.io

            M 1 Reply Last reply 25 Jul 2016, 10:07
            2
            • J Joel Bodenmann
              25 Jul 2016, 09:41

              Thank you for your comment! Apparently the proper fix to this problem is me stopping to have weird-behavior expectations of my software :p

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 25 Jul 2016, 10:07 last edited by
              #6

              @Joel-Bodenmann

              Well actually its not super weird. If you active
              accessibility settings in windows, (on some pads)
              you can get this for drag & drop to help
              people where is hard to hold down mouse. :)

              1 Reply Last reply
              0

              1/6

              23 Jul 2016, 14:06

              • Login

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