QT各种控件风格设置(Change styleSheet...)

1、checkbox.qss

QCheckBox::indicator:unchecked
{
    image: url(:/assist/icon/assist-uncheck.png);
}

QCheckBox::indicator:unchecked:hover
{
    image: url(:/assist/icon/assist-uncheck-hover.png);
}

QCheckBox::indicator:checked
{
    image: url(:/assist/icon/assist-check.png);
}

QCheckBox::indicator:checked:hover
{
    image: url(:/assist/icon/assist-check-hover.png);
}

2、combobox.qss

QComboBox 
{
    border: 1px solid gray;
    border-radius: 3px;
    padding: 1px 5px 1px 3px;
}

QComboBox:!editable, QComboBox::drop-down:editable
{
     background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
}

QComboBox:!editable:on, QComboBox::drop-down:editable:on
{
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D3D3D3, stop: 0.4 #D8D8D8, stop: 0.5 #DDDDDD, stop: 1.0 #E1E1E1);
}

QComboBox:on
{
    padding-top: 3px;
    padding-left: 4px;
}

QComboBox::drop-down
{
    subcontrol-origin: padding;
    subcontrol-position: top right;
    width: 15px;

    border-left-width: 1px;
    border-left-color: darkgray;
    border-left-style: solid;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
}

QComboBox::down-arrow:on
{
    top: 1px;
    left: 1px;
}

QComboBox::down-arrow
{
    image: url(:/assist/icon/assist-arrow-down.png);
}

3、comboboxnodroparrow.qss

QComboBox 
{
    border: 1px solid gray;
    border-radius: 3px;
    padding: 1px 5px 1px 3px;
}

QComboBox:!editable, QComboBox::drop-down:editable
{
     background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
}

QComboBox:!editable:on, QComboBox::drop-down:editable:on
{
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D3D3D3, stop: 0.4 #D8D8D8, stop: 0.5 #DDDDDD, stop: 1.0 #E1E1E1);
}

QComboBox:on
{
    padding-top: 3px;
    padding-left: 4px;
}

QComboBox::drop-down
{
    subcontrol-origin: padding;
    subcontrol-position: top right;
    width: 0px;

    border-left-width: 1px;
    border-left-color: darkgray;
    border-left-style: solid;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
}

QComboBox::down-arrow:on
{
    top: 1px;
    left: 1px;
}

QComboBox::down-arrow
{
    image: url(/noimage);
}
4、comboboxred.qss

QComboBox 
{
    border: 3px solid red;
    background: red;
    border-radius: 3px;
    padding: 1px 5px 1px 3px;
}

QComboBox:!editable, QComboBox::drop-down:editable
{
     background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
}

QComboBox:!editable:on, QComboBox::drop-down:editable:on
{
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D3D3D3, stop: 0.4 #D8D8D8, stop: 0.5 #DDDDDD, stop: 1.0 #E1E1E1);
}

QComboBox:on
{
    padding-top: 3px;
    padding-left: 4px;
}

QComboBox::drop-down
{
    subcontrol-origin: padding;
    subcontrol-position: top right;
    width: 15px;

    border-left-width: 1px;
    border-left-color: darkgray;
    border-left-style: solid;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
}

QComboBox::down-arrow:on
{
    top: 1px;
    left: 1px;
}

QComboBox::down-arrow
{
    image: url(:/assist/icon/assist-arrow-down.png);
}
5、comboboxrednodroparrow.qss

QComboBox 
{
    border: 3px solid red;
    background: red;
    border-radius: 3px;
    padding: 1px 5px 1px 3px;
}

QComboBox:!editable, QComboBox::drop-down:editable
{
     background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
}

QComboBox:!editable:on, QComboBox::drop-down:editable:on
{
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D3D3D3, stop: 0.4 #D8D8D8, stop: 0.5 #DDDDDD, stop: 1.0 #E1E1E1);
}

QComboBox:on
{
    padding-top: 3px;
    padding-left: 4px;
}

QComboBox::drop-down
{
    subcontrol-origin: padding;
    subcontrol-position: top right;
    width: 0px;

    border-left-width: 1px;
    border-left-color: darkgray;
    border-left-style: solid;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
}

QComboBox::down-arrow:on
{
    top: 1px;
    left: 1px;
}

QComboBox::down-arrow
{
    image: url(/noimage);
}

6、groupbox.qss

QGroupBox
{
   background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);
   border: 1px solid gray;
   border-radius: 5px;
   margin-top: 1ex;
}

QGroupBox::title
{
   subcontrol-origin: margin;
   subcontrol-position: top left;
   padding: 0 3px;
   border-top-left-radius: 3px;
   border-top-right-radius: 3px;
   background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E0E0E0, stop: 1 #FFFFFF);

7、menu.qss

QMenu
{
    background-color: rgba(201, 201, 202, 255);
    margin: 2px;
    font-size: 18pt;
}

QMenu::item
{
    padding: 3px 30px 3px 20px;
    border: 1px solid transparent;
}

QMenu::item:selected
{
    border-color: darkblue;
    background: rgba(165, 165, 165, 128);
}
8、menubar.qss

QMenuBar
{
   background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);
   border: 1px solid gray;
   font-size: 18pt;
}

QMenuBar::item
{
   margin: 1px 4px 4px;
   padding: 2px 4px;
   spacing: 4px;
   border-radius: 4px;
   border-width: 1px solid gray;
   background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);
}

QMenuBar::item:selected
{
   border-width: 1px solid darkgray;
   background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(201, 201, 201, 255),
   stop:0.45 rgba(165, 165, 165, 255), stop:1 rgba(201, 201, 202, 255));
   font:#BBDDFF;
}

QMenuBar::item:pressed
{
   border-width: 1px solid darkgray;
   background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(165, 165, 165, 255),
   stop:0.45 rgba(148, 148, 148, 255), stop:1 rgba(165, 165, 165, 255));
   font:#BBDDFF;
}
9、radiobutton.qss

QRadioButton
{
    font: 16px;
}

QRadioButton:hover
{
    background-color: rgb(252, 228, 218);
}

QRadioButton::indicator::unchecked

    border: 1px solid darkgray; 
    border-radius: 8px; 
    background-color: white; 
    width:16px; 
    height: 16px; 
    margin-left: 1px;
}

QRadioButton::indicator::unchecked:hover

    border: 1px solid darkgray; 
    border-radius: 8px; 
    background-color: white; 
    width:16px; 
    height: 16px; 
    margin-left: 1px;
}

QRadioButton::indicator::checked

    border: 1px solid darkgray; 
    border-radius: 8px; 
    background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(41, 41, 41, 255), stop:0.5 rgba(41, 41, 41, 255), stop:0.7 rgba(0, 0, 0, 0));
    width: 16px; 
    height: 16px; 
    margin-left: 1px;
}

QRadioButton::indicator::checked:hover

    border: 1px solid darkgray; 
    border-radius: 8px; 
    background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0.15 rgba(0, 0, 0, 0), stop:0.3 rgba(255, 255, 255, 255), stop:0.45 rgba(41, 41, 41, 255), stop:0.60 rgba(41, 41, 41, 255), stop:0.7 rgba(0, 0, 0, 0));
    width: 16px; 
    height: 16px; 
    margin-left: 1px;
}
10、tooltip.qss

QToolTip
{
    padding: 1px;
    font-size: 20pt;
    border: 1px solid black;
    background: rgb(255, 255, 220);
}
11、treeviewcheckbox.qss

QTableView::indicator:unchecked
{
    image: url(:/assist/icon/assist-uncheck.png);
}

QTableView::indicator:unchecked:hover
{
    image: url(:/assist/icon/assist-uncheck-hover.png);
}

QTableView::indicator:checked
{
    image: url(:/assist/icon/assist-check.png);
}

QTableView::indicator:checked:hover
{
    image: url(:/assist/icon/assist-check-hover.png);
}
 

你可能感兴趣的:(QT)