好的,使用Qt,我想知道如何在任何时间点检测鼠标的当前状态 – 没有MouseEvent.
使用QCursor :: pos(),您可以获得它的位置,但有没有办法确定按钮的当前状态?
基本上,我希望在计时器关闭时验证鼠标的状态,因此它不会与任何特定的MouseEvent相关,因此没有要查询的MouseEvent.我需要知道如何查询鼠标的状态 – 特别是按钮的状态 – 没有MouseEvent.
解决方法
Qt::MouseButtons QApplication::mouseButtons () [static]:
Returns the current state of the buttons on the mouse. The current
state is updated syncronously as the event queue is emptied of events
that will spontaneously change the mouse state (QEvent::MousePress
and
QEvent::MouseRelease
events).It should be noted this may not reflect the actual buttons held on
theinput device at the time of calling but rather the mouse buttons as
last reported in one of the above events. If no mouse buttons are
being heldQt::NoButton
is returned.
编辑:嗯,我刚刚注意到你问过Qt3.3.这个答案适用于Qt4我害怕.