Qt实用技巧:使用非透明窗体鼠标穿透到桌面的设置方法

若该文为原创文章,未经允许不得转载
原博主博客地址:https://blog.csdn.net/qq21497936
原博主博客导航:https://blog.csdn.net/qq21497936/article/details/102478062
本文章博客地址:https://blog.csdn.net/qq21497936/article/details/91491282
各位读者,知识无穷而人力有穷,要么改需求,要么找专业人士,要么自己研究

红胖子(红模仿)的博文大全:开发技术集合(包含Qt实用技术、树莓派、三维、OpenCV、OpenGL、ffmpeg、OSG、单片机、软硬结合等等)持续更新中…(点击传送门)

 

Qt开发专栏:实用技巧(点击传送门)

 

需求

        实现桌面画板工具,发现调试过程中,无法穿透非透明窗口到桌面(有画笔颜色)

 

设置方法

// 一定要先设置鼠标床头,否则无法穿透,应该是属性中间有值影响
setAttribute(Qt::WA_TransparentForMouseEvents, true);

setWindowFlag(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground, true);

 

入坑

// 一定要先设置鼠标穿透,否则无法穿透,此代码窗口无法穿透
setWindowFlag(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TransparentForMouseEvents, true);
setAttribute(Qt::WA_TranslucentBackground, true);

 

原博主博客地址:https://blog.csdn.net/qq21497936
原博主博客导航:https://blog.csdn.net/qq21497936/article/details/102478062
本文章博客地址:https://blog.csdn.net/qq21497936/article/details/91491282

你可能感兴趣的:(#,Qt实用技巧)