QT 製作視窗圓角

2021-07-24 07:22:13 字數 441 閱讀 2588

一、設定視窗屬性

setwindowflags(qt::framelesswindowhint | qt::windowsystemmenuhint | qt::windowminmaxbuttonshint);

setattribute(qt::wa_translucentbackground);

二、使用qss新增圓角

#titlewnd

#mainwnd

titlewnd是我的標題容器qwidget,左上角和右上角設定圓角

mainwnd是我的內容容器qwidget,左下角和右下角設定圓角

三、效果如下:

QT圓角視窗

以前寫的qt圓角都是在paintevent中繪製圓角背景,但是如果圓角附近需要放控制項,控制項就會因為自己的重繪而跑到圓角的外面去了,還有一種辦法就是設定setmask,自己控制 需要顯示,不需要顯示,bmp填充為乙個黑色圓角矩形,就能讓視窗的可見區域侷限於圓角矩形內,即使控制項越界也不會顯示出來。...

QT實現視窗圓角

實現上邊角圓弧 setwindowflags qt framelesswindowhint qbitmap bmp this size bmp.fill qpainter p bmp p.setpen qt nopen p.setbrush qt black p.setrenderhint qpai...

qt 設定視窗圓角

最近在用qss做介面美化的工作,發現乙個問題就是qss不能對頂級視窗設定邊角圓弧,於是得另闢蹊徑。據網上搜尋可得到的方法我實現了三種 cpp view plain copy setwindowflags qt framelesswindowhint qbitmap bmp this size bmp...