读书人

QT 父控件设置为透明背景后如何设置

发布时间: 2013-07-01 12:33:04 作者: rapoo

QT 父控件设置为透明背景后,怎么设置子控件的透明度
使用 setWindowOpacity 无效果

重写 paintEvent 可以实现这个效果,但控件样式较多,自己绘制比较麻烦

setStyleSheet 可不可以,只改变透明度,不影响其他外观

[解决办法]
setWindowOpacity 可以啊 除非你是在linux上
[解决办法]
看看Qt::WA_TranslucentBackground的解释

Indicates that the widget should have a translucent background, i.e., any non-opaque regions of the widgets will be translucent because the widget will have an alpha channel. Setting this flag causes WA_NoSystemBackground to be set. On Windows the widget also needs the Qt::FramelessWindowHint window flag to be set. This flag is set or cleared by the widget's author.
[解决办法]
paintEvent如何让控件透明啊

读书人网 >QT开发

热点推荐