加入收藏 | 设为首页57365线路检测中
 365bet线路检测
Qt的格式是透明的。
发布时间:2019-02-06 点击:
简单
关于常见形式的透明度,以下是常用透明效果的描述。
透明主窗体(不透明子窗体)透明子窗体(主窗体不透明)透明主窗体(透明窗体)
正常状态
在正常条件下,效果如下。
完全透明
在这里,我们可以看到整个桌子的桌子底部。
效果
源代码
如下调整窗口的透明度。
setWindowOpacity(0。
5);
透明度值范围:0
0(完全透明)-1
0(不透明),默认值为1。
0
主要形式的透明度
在这里,您可以通过表单的一部分看到桌面的底部。
效果
源代码
使用paintEvent绘制背景
主窗体使用背景颜色。
voidMainWindow:paintEvent(QPaintEvent event *)
Q_UNUSED(事件)。
Q画家画家(东)
// QColor的最后一个参数80表示通常用作透明度的alpha通道
画家
fillRect(rect(),QColor(50,50,50,80));
主窗体使用背景图像。
首先,设置背景的透明度。
setAttribute(Qt:WA_TranslucentBackground,true);
接下来,绘制表单的背景。
voidQZXingWidget:paintEvent(事件QPaintEvent *)
QPixmapcovertPixmap(:/ Images / background);
QPixmappixmap(covertPixmap。
宽度(),covertPixmap。
高度());
像素图。
填充(Qt:透明)。
QPainterpainter(pixmap);
QPointstart_point(0,0);
QPointend_point(0,Pixmap。
高度());
//用于渐变颜色设置的QLinearGradient
QLinearGradientgradient(start_point,end_point);
梯度
setColorAt(0,QColor(255,255,255,100));
梯度
setColorAt(0。
5,Q颜色(255,255,255,150))。
梯度
setColorAt(1,QColor(255,255,255,255));
画家
fillRect(rect(),QBrush(gradient));
画家
setCompositionMode(QPainter:CompositionMode_SourceIn);
画家
drawPixmap(0,0,covertPixmap);
画家
终止();
Q Painter Painter 2(东部)。
画家2。
drawPixmap(0,0,pixmap);