鼠标穿透参考方法:
1. QWidget::setMask(QRegion(childrenRegion()));
2. setAttribute(Qt::WA_TransparentForMouseEvents,true); //设置该属性窗口的子控件不能再响应鼠标消息
3. 透明popup window窗口
setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
setAttribute(Qt::WA_TranslucentBackground,true);
Qt::Tool类型窗口,不设置WA_TransparentForMouseEvents也能鼠标穿透
setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
setAttribute(Qt::WA_TranslucentBackground, true);
2. 对于非Qt::Window窗口,则需要先设置WA_TransparentForMouseEvents
// 一定要先设置鼠标穿透,否则无法穿透
setAttribute(Qt::WA_TransparentForMouseEvents, true);
setWindowFlag(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground, true);
3. 如果Qt窗口装入了Win32 popup透明窗口,用于加载CEF浏览器进程透明背景web页面,则Qt窗口即使透明背景,鼠标也无法穿透
对于 动画子控件,不知如何响应鼠标穿透消息?