我们知道在setOpacity中设置了setWindowOpacity可以改变窗体透明度, 这样的代码在主窗体中是有效的, 但是在窗口的某一个部件中却是无效的.表现为设置之后透明度没有变化.在帮助文档中写有Warning: Changing this property from opaque to transparent might issue a paint event that needs to be processed before the window is displayed correctly.
所以需要这样处理
QGraphicsOpacityEffect *m_pGraphicsOpacityEffect = new QGraphicsOpacityEffect(this);this->setGraphicsEffect(m_pGraphicsOpacityEffect );m_pGraphicsOpacityEffect ->setOpacity(m_opacity);这样就能有效设置透明度。
Qt 子窗体透明度设置
最新推荐文章于 2023-05-31 21:37:17 发布