Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] Using a custom mouse-cursor for QDrag

    General and Desktop
    2
    3
    1490
    Loading More Posts
    • 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
      thEClaw last edited by

      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 Reply Quote 0
      • A
        ambershark last edited by

        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 Reply Quote 0
        • T
          thEClaw last edited by

          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 Reply Quote 0
          • First post
            Last post