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] Using a custom mouse-cursor for QDrag
Forum Update on Monday, May 27th 2025

[Solved] Using a custom mouse-cursor for QDrag

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.8k 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.
  • T Offline
    T Offline
    thEClaw
    wrote on 23 Jul 2014, 16:39 last edited by
    #1

    This might be a difficult problem. I want to do a drag&drop operation that uses a custom cursor (not a sub-cursor but the "real" one). QDrag::setDragCursor only takes care of the sub-cursor and even QGuiApplication::setOverrideCursor does not help in changing the mouse cursor during a drag&drop operation. I always get a black arrow (might depend on the style of the application or the operating system).

    If I am just horribly stupid and missing an easy solution, please help me out. Otherwise I would appreciate any kind of idea of where this unchangeable cursor might come from. Maybe it can be changed by modifying Qt somehow.

    EDIT
    I gave up on QDrag and implemented a custom Drag&Drop - now one can drag around widgets directly instead of having to use QDrag and "faking" a moving widget by using a static pixmap. This speeds things up, allows for new possibilities, shortens the code but does not allow for communicating between different processes. ( "here":http://qt-project.org/forums/viewthread/46950/ is a bit more to read about it)

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on 25 Jul 2014, 22:09 last edited by
      #2

      Well something you could do is set the mouse cursor for the widget you are dragging in with QCursor.

      I don't know by your question if you want to change the cursor system wide or just in a certain widget.

      If it's widget only you can change the widget's cursor on a drag start event and change it back on a drag end event.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thEClaw
        wrote on 26 Jul 2014, 04:31 last edited by
        #3

        Setting the QCursor for a widget doesn't help, QDrag brings along its own cursor. Since it is dragging a pixmap and not the widget itself, the mouse wouldn't stay over the widget during the operation anyway.

        And even when I override the applications cursor (!), QDrag decides to use its own.

        I think I need to find a way to circumvent using QDrag altogether, it probably could use a complete rewrite.

        1 Reply Last reply
        0

        1/3

        23 Jul 2014, 16:39

        • Login

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