2

From what I see, QApplication::mouseButtons() may return no buttons even when a button is held down. This happens when you have clicked a side of a window for re-sizing. It's coherent with the docs because mouseButtons() reflects the state from the flow of QEvent::mouseButtonPress, etc. However, I need just to know if the button is held down. Does any one know if it's possible through the Qt API?

Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61
tru7
  • 6,348
  • 5
  • 35
  • 59

1 Answers1

2

I think it's not possible. Mouse events outside an application's window are not passed to its event handlers. Dragging mouse borders is one of such events, it's processed by the window system. Another example is clicking on other windows. Usually an application doesn't know what the user does with other windows. You need to install system-wide event listener or use native API features(e.g. GetAsyncKeyState on Windows) to determine that. This behavior is unusual and possibly dangerous. In most cases it's not useful, and it seems that Qt doesn't have this ability.

Pavel Strakhov
  • 39,123
  • 5
  • 88
  • 127
  • Yes, so it seems. But it wouldn't be that difficult to test the physical status of the button, outside the events system. – tru7 Jun 30 '13 at 21:35