網站首頁 編程語言 正文
透明效果
情況一
//窗口整個透明屬性,取值為0-1,0為全透明 setWindowOpacity(0.5);
情況二
//部件不透明,窗體背景完全透明,以下兩個函數必須配合使用 setWindowFlags(Qt::FramelessWindowHint);//窗口無邊框 setAttribute(Qt::WA_TranslucentBackground);//背景透明
情況三
//單個部件設置透明 //需要添加頭文件#include<QGraphicsOpacityEffect> QGraphicsOpacityEffect*opacityEffect=new QGraphicsOpacityEffect; opacityEffect->setOpacity(0.1); //0為完全透明,1為不透明 ui->label->setGraphicsEffect(opacityEffect);
情況四
窗口半透明,部件不透明:需要重寫paintEvent
setWindowFlags(Qt::FramelessWindowHint); //窗口無邊框 setAttribute(Qt::WA_TranslucentBackground);//背景透明 //重寫繪圖事件 void MainWindow::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.fillRect(rect(),QColor(255,255,255,200));//rect:填充矩形區域+rgb值+透明度為100 }
陰影效果
要添加頭文件#include<QGraphicsDropShadowEffect>
//陰影效果 QGraphicsDropShadowEffect*shadowEffect=new QGraphicsDropShadowEffect; //陰影色,透明色 shadowEffect->setColor(QColor(100,100,100)); shadowEffect->setBlurRadius(20);//陰影模糊半徑 shadowEffect->setOffset(20); //陰影偏移值 ui->label->setGraphicsEffect(shadowEffect);
原文鏈接:https://blog.csdn.net/Jacksqh/article/details/122722827
相關推薦
- 2022-08-29 如何利用Python寫猜數字和字母的游戲_python
- 2022-09-03 Python實現計算AUC的三種方式總結_python
- 2022-09-18 GO實現文件上傳操作_Golang
- 2022-08-05 C++深入探究哈希表如何封裝出unordered_set和unordered_map_C 語言
- 2022-07-04 Python如何一行輸入多個數,并存入列表_python
- 2022-10-12 Golang中panic的異常處理_Golang
- 2022-04-10 git本地提交到遠程倉庫報錯error: failed to push some refs to
- 2023-10-11 MP、MybatisPlus、聯表查詢、自定義sql、Constants.WRAPPER、ew (二
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支