Qt界面美化常用到样式表,用好样式表能达到不一样的效果。
常用控件样式表用法如下:
/**********子界面背景**********/
QWidget#customWidget {
background: rgb(68, 69, 73);
}
/**********子界面中央背景**********/
QWidget#centerWidget {
background: rgb(50, 50, 50);
}
/**********主界面样式**********/
QWidget#mainWindow {
border: 1px solid rgb(50, 50, 50);
background: rgb(50, 50, 50);
}
QWidget#messageWidget {
background: rgba(68, 69, 73, 50%);
}
QWidget#loadingWidget {
border: none;
border-radius: 5px;
background: rgb(50, 50, 50);
}
QWidget#remoteWidget {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
border: 1px solid rgb(45, 45, 45);
background: rgb(50, 50, 50);
}
StyledWidget {
qproperty-normalColor: white;
qproperty-disableColor: gray;
qproperty-highlightColor: rgb(0, 160, 230);
qproperty-errorColor: red;
}
QProgressIndicator {
qproperty-color: rgb(175, 175, 175);
}
/**********提示**********/
QToolTip{
border: 1px solid rgb(45, 45, 45);
background: white;
color: black;
}
/**********菜单栏**********/
QMenuBar {
background: rgb(57, 58, 60);
border: none;
}
QMenuBar::item {
padding: 5px 10px 5px 10px;
background: transparent;
}
QMenuBar::item:enabled {
color: rgb(227, 234, 242);
}
QMenuBar::item:!enabled {
color: rgb(155, 155, 155);
}
QMenuBar::item:enabled:selected {
background: rgba(255, 255, 255, 40);
}
/**********菜单**********/
QMenu {
border: 1px solid rgb(100, 100, 100);
background: rgb(68, 69, 73);
}
QMenu::item {
height: 22px;
padding: 0px 25px 0px 20px;
}
QMenu::item:enabled {
color: rgb(225, 225, 225);
}
QMenu::item:!enabled {
color: rgb(155, 155, 155);
}
QMenu::item:enabled:selected {
color: rgb(230, 230, 230);
background: rgba(255, 255, 255, 40);
}
QMenu::separator {
height: 1px;
background: rgb(100, 100, 100);
}
QMenu::indicator {
width: 13px;
height: 13px;
}
QMenu::icon {
padding-left: 2px;
padding-right: 2px;
}
/**********状态栏**********/
QStatusBar {
background: rgb(57, 58, 60);
}
QStatusBar::item {
border: none;
border-right: 1px solid rgb(100, 100, 100);
}
/**********分组框**********/
QGroupBox {
font-size: 15px;
border: 1px solid rgb(80, 80, 80);
border-radius: 4px;
margin-top: 10px;
}
QGroupBox::title {
color: rgb(175, 175, 175);
top: -12px;
left: 10px;
}
/**********页签项**********/
QTabWidget::pane {
border: none;
border-top: 3px solid rgb(0, 160, 230);
background: rgb(57, 58, 60);
}
QTabWidget::tab-bar {
border: none;
}
QTabBar::tab {
border: none;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
color: rgb(175, 175, 175);
background: rgb(255, 255, 255, 30);
height: 28px;
min-width: 85px;
margin-right: 5px;
padding-left: 5px;
padding-right: 5px;
}
QTabBar::tab:hover {
background: rgb(255, 255, 255, 40);
}
QTabBar::tab:selected {
color: white;
background: rgb(0, 160, 230);
}
QTabWidget#tabWidget::pane {
border: 1px solid rgb(45, 45, 45);
background: rgb(57, 58, 60);
margin-top: -1px;
}
QTabBar#tabBar::tab {
border: 1px solid rgb(45, 45, 45);
border-bottom: none;
background: transparent;
}
QTabBar#tabBar::tab:hover {
color: white;
}
QTabBar#tabBar::tab:selected {
color: white;
background: rgb(57, 58, 60);
}
/**********表头**********/
QHeaderView{
border: none;
border-bottom: 3px solid rgb(0, 160, 230);
background: rgb(57, 58, 60);
min-height: 30px;
}
QHeaderView::section:horizontal {
border: none;
color: white;
background: transparent;
padding-left: 5px;
}
QHeaderView::section:horizontal:hover {
background: rgb(0, 160, 230);
}
QHeaderView::section:horizontal:pressed {
background: rgb(0, 180, 255);
}
QHeaderView::up-arrow {
width: 13px;
height: 11px;
padding-right: 5px;
image: url(:/Black/topArrow);
subcontrol-position: center right;
}
QHeaderView::up-arrow:hover, QHeaderView::up-arrow:pressed {
image: url(:/Black/topArrowHover);
}
QHeaderView::down-arrow {
width: 13px;
height: 11px;
padding-right: 5px;
image: url(:/Black/bottomArrow);
subcontrol-position: center right;
}
QHeaderView::down-arrow:hover, QHeaderView::down-arrow:pressed {
image: url(:/Black/bottomArrowHover);
}
/**********表格**********/
QTableView {
border: 1px solid rgb(45, 45, 45);
background: rgb(57, 58, 60);
gridline-color: rgb(60, 60, 60);
}
QTableView::item {
padding-left: 5px;
padding-right: 5px;
border