经过验证,通过代码:
this->setAttribute(Qt::WA_TranslucentBackground, true);
在 UOS 上,可以实现窗口透明;
在 Windows 上,则本应透明的部分是全黑。
为了解决该问题,windows 平台需要加上如下代码才能实现透明:
this->setWindowFlag(Qt::FramelessWindowHint);
(SAW:Game Over!)
本文探讨了使用Qt库在UOS和Windows平台上实现窗口透明的效果。通过代码`setAttribute(Qt::WA_TranslucentBackground, true)`可以在UOS上创建透明窗口,但在Windows上同一代码会导致窗口全黑。为解决此问题,Windows平台需要额外添加`setWindowFlag(Qt::FramelessWindowHint)`来实现透明效果。这是一个关于跨平台UI开发中遇到的问题及其解决方案的实例。
经过验证,通过代码:
this->setAttribute(Qt::WA_TranslucentBackground, true);
在 UOS 上,可以实现窗口透明;
在 Windows 上,则本应透明的部分是全黑。
为了解决该问题,windows 平台需要加上如下代码才能实现透明:
this->setWindowFlag(Qt::FramelessWindowHint);
(SAW:Game Over!)

被折叠的 条评论
为什么被折叠?
