QT/c++ 如何判断全局是鼠标按下还是松开?
QT/c++ How to check globaly is mouse press or release?
void MainWindow::mousePressEvent(QMouseEvent* event)
{
if(event->button() == Qt::LeftButton)
{
timer->start(timer_time);
}
}
void MainWindow::mouseReleaseEvent(QMouseEvent* event)
{
if(event->button() == Qt::LeftButton)
{
timer->stop();
}
}
此代码在我的应用程序内部使用时有效,但如果我想在外部使用它,它将无法正常工作。我怎样才能做到这一点?
它应该在左键按下时启动计时器,在左键释放时停止。
解决方案: understanding-the-low-level-mouse-and-keyboard-hook-win32
void MainWindow::mousePressEvent(QMouseEvent* event)
{
if(event->button() == Qt::LeftButton)
{
timer->start(timer_time);
}
}
void MainWindow::mouseReleaseEvent(QMouseEvent* event)
{
if(event->button() == Qt::LeftButton)
{
timer->stop();
}
}
此代码在我的应用程序内部使用时有效,但如果我想在外部使用它,它将无法正常工作。我怎样才能做到这一点? 它应该在左键按下时启动计时器,在左键释放时停止。
解决方案: understanding-the-low-level-mouse-and-keyboard-hook-win32