pyqt中对样式的编辑是借鉴了css,qt的样式美化规则是叫qss,其语法与css一样,所以在我什么都不了解的时候,要去看一下css语法是怎样,
https://www.runoob.com/css/css-tutorial.html
菜鸟教程的css篇,看起来很多,静下来看3-4个小时就看完了,然后再看下qss,qss就是把css的里面类的名字换成了qt里面的控件,其他的几乎没什么变化,当然,qss是没有css强大的,所以有些功能可能无法使用,但是美化界面应该足够用了。
下面贴一个qss的文件,供参考:
QLineEdit#e1_serch{
border:1px solid gray;
width:300px;
border-radius:10px;
padding:2px 4px;
background-image: url(:/icon/images/icon/fangdajing.png);
background-repeat: no-repeat;
background-position: left;
padding: 2 2 2 30;
}
QPushButton#new_Button{
font-family: "Microsoft YaHei";
font-weight: bold;
border:1px solid gray;
border-radius: 14px;
color: black;
background-color: transparent;
}
QPushButton#new_Button:hover{
font-family: "Microsoft YaHei";
font-weight: bold;
border-radius: 14px;
color: black;
background-color: #21aefa;
}
QPushButton#upload_Button{
font-family: "Microsoft YaHei";
font-weight: bold;
border:1px solid gray;
border-radius: 14px;
color: black;
background-color:transparent;
}
QPushButton#upload_Button:hover{
font-family: "Microsoft YaHei";
font-weight: bold;
border-radius: 14px;
color: black;
background-color: #21aefa;
}
QPushButton#e1_message{
border: none;
}
QPushButton#user_info_Button{
border: none;
}
QPushButton#copy_Button{
border: none;
}
QPushButton#edit_Button{
border: none;
}
QPushButton#pushButton_2{
border: none;
}
QPushButton#pushButton_4{
border: none;
}
QTabWidget:pane
{
border-top: 1px solid #E5E5E5;
border-left:1px solid #E5E5E5;
position: absolute;
font-size: 14px;
}
QTabWidget:tab-bar {
border-bottom: 2px solid #E5E5E5;
border-left:1px solid #E5E5E5;
alignment: left;
font-size: 14px;
}
QTabBar:tab {
border: none;
border-bottom-color: #C2C7CB; /* same as the pane color */
border-top-left-radius: 4px;
border-top-right-radius: 4px;
min-width: 60px;
width:60px;
padding: 2px;
font-size: 14px;
}
QTabBar:tab:hover {
color:#2080F7;
}
QTabBar:tab:selected {
color:#2080F7;
border-bottom: 2px solid #2080F7;
font-weight:bold;
}
/* QPushButton{border:none;color:black;} */
QLabel{background:white;}
QLabel{color:rgb(100,100,100,25%);font-size:15px;font-weight:bold;font-family:Roman times;}
QLabel:hover{color:rgb(100,100,100,12%);}")
QScrollBar::handle{background:rgba(0,0,0,50%); border:2px solid transparent; border-radius:5px; }
QScrollBar::handle:hover{background:rgba(0,0,0,50%);border:0px rgba(0,0,0,25%); }