PyQt5 樣式美化之初體驗
在Designer中,通過編輯StyleSheet對界面進行了美化。
深感CSS的重要性,許久沒用,好多都忘了,得好好補補。不過在幫助文檔的援助下,順利完成任務~
運行界面
個人感覺美美噠~突然好喜歡綠色。
代碼
QPushButton{
background-color:rgb(0, 170, 127);
font-size:20px;
color:rgb(255, 255, 255);
font-weight:bold;
border-radius: 10px;
}
QTextEdit{
font-size:28px;
font-weight:bold;
color:rgb(255, 255, 255);
letter-spacing:5px;
outline-color:rgb(255, 255, 255);
border-radius:10px;
background-color:rgba(0, 170, 127, 100)
}
QWidget::Form{
background-color:rgba(0, 170, 127, 100)
}
存在的問題
我使用的窗體是Designer中的QWidget,在編輯樣式表的過程中,不知道要怎樣實現只對窗體進行編輯。
QWidget{
background-color:rgba(0, 170, 127, 100)
}
如果是上面這樣設置,則所有QWidget都設置成了這個樣式。
QWidget::Form{
background-color:rgba(0, 170, 127, 100)
}
看到有大佬說,::的方式可以選取子控件,代碼如上所示,我試了之後還是沒有成功, 求大佬幫助~
難道是真的只能以python編程實現這個樣式的更改嘛  ̄へ ̄
其他相關資料
-
修改樣式的三種方法對比:
https://blog.csdn.net/GoForwardToStep/article/details/60884870 -
QSS樣式表語法及教程:
https://blog.csdn.net/u011012932/category_9605197.html
https://www.cnblogs.com/itrena/p/5938314.html
有緣看到的小夥伴,給人家點個讚唄~麼麼噠❤