1.头文件,重写:
bool winEvent(MSG *msg, long *result);2.注册热键:
::RegisterHotKey(this->winId(), 100,0, VK_F2);3.处理Windows消息:
bool YYKengDieButton::winEvent(MSG *msg, long *result){if(msg->message==WM_HOTKEY){
if(msg->wParam==100)timer->stop();}
return false;}
4.重写关闭事件、卸载热键:
void YYKengDieButton::closeEvent(QCloseEvent *event)
{
::UnregisterHotKey(this->winId(),100);
}