Qt中CQGUI框架之陰影圓角窗口實(shí)現(xiàn)
大家好,我是IT文藝男,來(lái)自一線(xiàn)大廠(chǎng)的一線(xiàn)程序員
今天給大家講解基于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++中的auto自動(dòng)類(lèi)型推導(dǎo)
C++標(biāo)準(zhǔn)委員會(huì)在C++11標(biāo)準(zhǔn)中改變了auto關(guān)鍵字的語(yǔ)義,使它變成一個(gè)類(lèi)型占位符,允許在定義變量時(shí)不必明確寫(xiě)出確切的類(lèi)型,讓編譯器在編譯期間根據(jù)初始值自動(dòng)推導(dǎo)出它的類(lèi)型,下面我們就來(lái)看看auto自動(dòng)類(lèi)型推導(dǎo)的推導(dǎo)規(guī)則吧2024-04-04C++實(shí)現(xiàn)圖書(shū)信息管理系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)圖書(shū)信息管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03C語(yǔ)言詳解float類(lèi)型在內(nèi)存中的存儲(chǔ)方式
在c語(yǔ)言中float函數(shù)是單精度的。它在內(nèi)存中以二進(jìn)制的形式存儲(chǔ)。分為符號(hào)位,階碼與尾數(shù)三部分,下面我們?cè)敿?xì)來(lái)了解一下2022-04-04C/C++中時(shí)間庫(kù)函數(shù)的使用詳解
這篇文章主要為大家詳細(xì)介紹了C/C++中的時(shí)間相關(guān)知識(shí)總結(jié),例如時(shí)間庫(kù)函數(shù)的使用以及獲取本地時(shí)間的不同方法,文中的示例代碼講解詳細(xì),需要的可以參考一下2022-11-11