【发布时间】:2017-07-13 17:16:50
【问题描述】:
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();
}
}
当我在我的应用程序中使用它时,此代码有效,但如果我想在外部使用它,它将无法工作。我怎样才能做到这一点? 它应该在按下 LeftButton 时启动计时器,并在 LeftButton 释放时停止。
解决方案: understanding-the-low-level-mouse-and-keyboard-hook-win32
【问题讨论】:
-
“但是如果我想在外面使用” 请详细说明,在外面使用是什么意思?
-
@Damian Sośnicki 你想从你的应用程序中获取鼠标事件吗?
-
是的,我想要它。我得到它。现在我有另一个问题。我在 MatTheWhale 的回答的评论中描述了它。