Qt中CQGUI框架之陰影圓角窗口實(shí)現(xiàn)
大家好,我是IT文藝男,來(lái)自一線大廠的一線程序員
今天給大家講解基于C++/Qt的CQGUI框架的陰影圓角窗口實(shí)現(xiàn),實(shí)現(xiàn)效果如下圖所示::

CQGUI開(kāi)發(fā)環(huán)境::
- Microsoft Visual Studio 2019
- Qt5.15.1
步驟如下:
一、繼承關(guān)系
class LoginPanel : public QDialog
二、窗口屬性
setAttribute(Qt::WA_TranslucentBackground); //設(shè)置頂層面板背景透明 setWindowFlags(Qt::FramelessWindowHint); //設(shè)置無(wú)邊框 setContentsMargins(10, 10, 10, 10);
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.
三、設(shè)置陰影效果
auto *defaultShadow = new QGraphicsDropShadowEffect(); defaultShadow->setBlurRadius(10.0); defaultShadow->setColor(QColor(0, 0, 0, 160)); defaultShadow->setOffset(0, 0); _loginMainFrm->setGraphicsEffect(defaultShadow);
四、設(shè)置樣式
QFrame#loginMainFrm>QFrame#leftFrame{
background:rgba(255,255,255,0.9);
border-top-left-radius:6px;
border-top-right-radius:0px;
border-bottom-right-radius:0px;
border-bottom-left-radius:6px;
}
五、事件響應(yīng)
protected: void mousePressEvent(QMouseEvent *e) override ; void mouseReleaseEvent(QMouseEvent *e) override ; void mouseMoveEvent(QMouseEvent *e) override ; void closeEvent(QCloseEvent *e) override ; bool event(QEvent* e) override ; protected: bool eventFilter(QObject* o, QEvent* e) override;
到此這篇關(guān)于Qt中CQGUI框架之陰影圓角窗口實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)CQGUI陰影圓角窗口內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C語(yǔ)言中改變目錄的相關(guān)操作函數(shù)詳解
這篇文章主要介紹了C語(yǔ)言中改變目錄的相關(guān)操作函數(shù)詳解,分別是fchdir()函數(shù)和rewinddir()函數(shù)的使用方法,需要的朋友可以參考下2015-09-09
C++ 中"emplace_back" 與 "push_back" 的區(qū)別
這篇文章主要介紹了C++ 中"emplace_back" 與 "push_back" 的區(qū)別的相關(guān)資料,需要的朋友可以參考下2017-04-04
C++實(shí)現(xiàn)學(xué)校運(yùn)動(dòng)會(huì)管理系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)學(xué)校運(yùn)動(dòng)會(huì)管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-10-10
C語(yǔ)言實(shí)現(xiàn)頁(yè)面置換算法
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)頁(yè)面置換算法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-12-12
使用c++調(diào)用windows打印api進(jìn)行打印的示例代碼
這篇文章主要介紹了使用c++調(diào)用windows打印api進(jìn)行打印的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06
C++?用紅黑樹(shù)模擬實(shí)現(xiàn)set、map的示例代碼
set、map的底層結(jié)構(gòu)是紅黑樹(shù),它們的函數(shù)通過(guò)調(diào)用紅黑樹(shù)的接口來(lái)實(shí)現(xiàn),本文主要介紹了C++?用紅黑樹(shù)模擬實(shí)現(xiàn)set、map,具有一定的參考價(jià)值,感興趣的可以了解一下2024-03-03
C++實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)(完整版)
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)學(xué)生信息管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-06-06

