《qss样式表笔记大全(二):可设置样式的窗口部件列表(上)(包含相关示例)》
生活随笔
收集整理的這篇文章主要介紹了
《qss样式表笔记大全(二):可设置样式的窗口部件列表(上)(包含相关示例)》
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
**
可設置樣式的窗口部件列表
QAbstractScrollArea(滾動區域:隨視口滾動背景、固定背景)
**
擴展:固定平鋪拉伸滿視口背景
QTextEdit{border-image: url(E:/1.jpg); }
示例:QCheckBox::indicator定制
QCheckBox {spacing: 5px; } QCheckBox::indicator {width: 13px;height: 13px; } QCheckBox::indicator:unchecked {background-color: rgb(60, 0, 0); } QCheckBox::indicator:unchecked:hover {background-color: rgb(120, 0, 0); } QCheckBox::indicator:unchecked:pressed {background-color: rgb(180, 0, 0); } QCheckBox::indicator:checked {background-color: rgb(0, 60, 0); } QCheckBox::indicator:checked:hover {background-color: rgb(0, 120, 0); } QCheckBox::indicator:checked:pressed {background-color: rgb(0, 180, 0); } QCheckBox::indicator:indeterminate:hover {background-color: rgb(0, 0, 255); } QCheckBox::indicator:indeterminate:pressed {background-color: rgb(0, 0, 255, 100); }
示例:QComboBox定制
QComboBox {border: 1px solid gray; /* border: 寬度 線類型 顏色 */border-radius: 3px;padding: 1px 18px 1px 3px;min-width: 6em; } QComboBox:editable {background: white; } 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 gets the "on" state when the popup is open */ 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 { /* shift the text when the popup opens */padding-top: 3px;padding-left: 4px; } QComboBox::drop-down {subcontrol-origin: padding;subcontrol-position: top right;width: 15px;border-left-width: 1px; border-left-style: solid; /* just a single line */border-left-color: darkgray;border-top-right-radius: 3px; /* same radius as the QComboBox */border-bottom-right-radius: 3px; } QComboBox::down-arrow {/* image: url(E:/1.jpg);*/border-image: url(E:/1.jpg); } QComboBox::down-arrow:on { /* shift the arrow when popup is open */top: 1px;left: 1px; }
注意:增加test1 test22… 單項的高度(ui->comboBox->setView(new QListView(); 添加圖片),
原來是如下:
QDateEdit(參照QSpinBox)
QDialogButtonBox
QDockWidget
QDoubleSpinBox(查看QSpinBox)
QFrame
示例:QFrame定制
QFrame, QLabel, QToolTip{border: 2px solid green; /* border: 寬度 線類型 顏色 */border-radius: 4px;padding: 2px; /* 邊界都內部矩形的寬度 */ background-image: url(E:/1.jpg); }QGroupBox
示例:QGroupBox定制
QGroupBox {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #E0E0E0, stop: 1 #FFFFFF);border: 2px solid gray; /* 右圖border: 4px solid gray; */border-radius: 5px;margin-top: 1ex; /* 右圖margin-top: 4ex; */ } QGroupBox::title {subcontrol-origin: margin;subcontrol-position: top center; /* position at the top center */padding: 0 3px;background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #FF0ECE,stop: 1 #FFFFFF); }
當在代碼或者ui中將GroupBox設置為checkable=true時,如下:
示例:QTableWidget的QHeaderView定制
QHeaderView::section {background-color: qlineargradient( x1:0, y1:0, x2:0, y2:1,stop:0 #616161, stop: 0.5 #505050,stop: 0.6 #434343, stop:1 #656565);color: white;padding-left: 4px;border: 1px solid #6c6c6c; } QHeaderView::section:checked {background-color: red; } /* 以下圖標,只有在設置允許sortingEnable排序后,點擊表頭才會出現*/ QHeaderView::down-arrow {width:24px;height:24px;image: url(E:/arrow-down.jpg); } QHeaderView::up-arrow {width:24px;height:24px;image: url(E:/arrow-up.jpg); }總結
以上是生活随笔為你收集整理的《qss样式表笔记大全(二):可设置样式的窗口部件列表(上)(包含相关示例)》的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: qss样式表笔记大全(一):qss名词解
- 下一篇: go get国内解决办法汇总