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. mouseMoveEvent problems
QtWS25 Last Chance

mouseMoveEvent problems

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 690 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.
  • Z Offline
    Z Offline
    Zogspot
    wrote on last edited by
    #1

    I'm having a problem with mouseMoveEvent. I've got some widgets that I'm dragging and dropping around. I'm doing fine with mousePressEvent, mouseMoveEvent and mouseReleaseEvent up to a point. I want to pick a widget up, out of its parent window and set it free, or put it in another parent window.

    When I click on the widget, I catch the mousePressEvent and call: setParent(topWindow, Qt::Tool | Qt::FramelessWindowHint | Qt::CustomizeWindowHint); where topWindow is a top level QMainWindow. The problem is that this eventually calls QWidgetPrivate::deactivateWidgetCleanup() which sets qt_button_down = 0. This makes it impossible to catch further mouseMoveEvents, even though the mouse button is still down over the widget.

    Is there some way to set qt_button_down back to myWidgetPointer? Or maybe send my own mousePressEvent which will then set qt_button_down back to myWidgetPointer?

    Thanks for any help.

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      Zogspot
      wrote on last edited by
      #2

      Ok, I've solved this -- or at least found a work-around. Wrap the setParent() function with setAttribute(Qt::WA_WState_Hidden, true); and setVisible(true); like this:

      setAttribute(Qt::WA_WState_Hidden, true);
      setParent(topWindow, Qt::Tool | Qt::FramelessWindowHint | Qt::CustomizeWindowHint);
      setVisible(true);
      

      This fools Qt into thinking the widget wasn't shown in the first place so it doesn't remove its mouse-button-down state.

      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