qt qss样式文件示例-深色主题(Dark Theme)

qt qss样式文件示例

/* ========================================
   深色主题(Dark Theme)完整样式表
   配色方案:深灰底 + 浅灰字 + 蓝强调色
   ======================================== */

/* ========== 全局基础样式 ========== */
* {
    background: #1E1E1E;
    color: #E0E0E0;
    selection-background-color: #409EFF;
    selection-color: #FFFFFF;
}

/* ========== 顶层窗口容器 ========== */
QMainWindow, QDialog, QWidget {
    background: #1E1E1E;
}

/* ========== 文本输入框组 ========== */
QLineEdit, QTextEdit, QPlainTextEdit {
    background: #2D2D30;
    color: #E0E0E0;
    border: 1px solid #3E3E42;
    border-radius: 4px;
    padding: 6px 10px;
}

QLineEdit:focus, QTextEdit:focus {
    border-color: #409EFF;
}

QLineEdit:disabled {
    background: #252526;
    color: #6A6A6A;
}

QLineEdit::placeholder {
    color: #A0A0A0;
}

/* ========== 按钮基础样式 ========== */
QPushButton {
    background: #2D2D30;
    color: #E0E0E0;
    border: 1px solid #3E3E42;
    border-radius: 4px;
    padding: 6px 16px;
}

QPushButton:hover {
    background: #3E3E42;
}

QPushButton:pressed {
    background: #252526;
}

QPushButton:disabled {
    color: #6A6A6A;
    background: #252526;
}

/* 主色调强调按钮 */
QPushButton[type="primary"] {
    background: #409EFF;
    color: white;
    border: none;
}

QPushButton[type="primary"]:hover {
    background: #66B1FF;
}

QPushButton[type="primary"]:pressed {
    background: #337ECC;
}

/* 危险操作按钮 */
QPushButton[type="danger"] {
    background: #F56C6C;
    color: white;
    border: none;
}

QPushButton[type="danger"]:hover {
    background: #F78989;
}

/* ========== 文本标签Label ========== */
QLabel {
    color: #E0E0E0;
}

QLabel:disabled {
    color: #6A6A6A;
}

/* ========== 表格、列表、树形控件 ========== */
QTableView, QListWidget, QTreeView {
    background: #1E1E1E;
    color: #E0E0E0;
    alternate-background-color: #252526;
    gridline-color: #3E3E42;
    border: none;
}

QTableView::item, QListWidget::item, QTreeView::item {
    padding: 4px 8px;
}

QTableView::item:hover, QListWidget::item:hover, QTreeView::item:hover {
    background: #2D2D30;
}

QTableView::item:selected, QListWidget::item:selected, QTreeView::item:selected {
    background: #409EFF;
    color: white;
}

/* ========== 表头样式 ========== */
QHeaderView::section {
    background: #252526;
    color: #E0E0E0;
    padding: 6px 10px;
    border: none;
    border-right: 1px solid #3E3E42;
    border-bottom: 1px solid #3E3E42;
    font-weight: bold;
}

/* ========== 滚动条(垂直+水平) ========== */
/* 垂直滚动条 */
QScrollBar:vertical {
    width: 8px;
    background: transparent;
}

QScrollBar::handle:vertical {
    background: #3E3E42;
    border-radius: 4px;
    min-height: 50px;
    margin: 2px;
}

QScrollBar::handle:vertical:hover {
    background: #4A4D55;
}

QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
    height: 0px;
    background: none;
}

/* 水平滚动条 */
QScrollBar:horizontal {
    height: 8px;
    background: transparent;
}

QScrollBar::handle:horizontal {
    background: #3E3E42;
    border-radius: 4px;
    min-width: 50px;
    margin: 2px;
}

QScrollBar::handle:horizontal:hover {
    background: #4A4D55;
}

QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal {
    width: 0px;
    background: none;
}

/* ========== 菜单栏、右键菜单 ========== */
QMenuBar {
    background: #252526;
    color: #E0E0E0;
}

QMenuBar::item:selected {
    background: #3E3E42;
}

QMenu {
    background: #2B2B2B;
    color: #E0E0E0;
    border: 1px solid #3E3E42;
}

QMenu::item:selected {
    background: #409EFF;
    color: white;
}

/* ========== 下拉选择框QComboBox ========== */
QComboBox {
    background: #2D2D30;
    color: #E0E0E0;
    border: 1px solid #3E3E42;
    border-radius: 4px;
    padding: 4px 10px;
}

QComboBox:hover {
    border-color: #409EFF;
}

QComboBox::drop-down {
    border: none;
}

QComboBox::down-arrow {
    image: url(:/icons/down-arrow-light.svg);
    width: 12px;
    height: 12px;
}

QComboBox QAbstractItemView {
    background: #2B2B2B;
    color: #E0E0E0;
    selection-background-color: #409EFF;
    selection-color: white;
}

/* ========== 标签页TabWidget ========== */
QTabWidget::pane {
    border: 1px solid #3E3E42;
    background: #1E1E1E;
}

QTabBar::tab {
    background: #252526;
    color: #A0A0A0;
    padding: 8px 16px;
    border: 1px solid #3E3E42;
    border-bottom: none;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

QTabBar::tab:selected {
    background: #2D2D30;
    color: #E0E0E0;
}

QTabBar::tab:hover {
    background: #3E3E42;
}

/* ========== 进度条ProgressBar ========== */
QProgressBar {
    background: #252526;
    border: 1px solid #3E3E42;
    border-radius: 4px;
    text-align: center;
    color: #E0E0E0;
}

QProgressBar::chunk {
    background: #409EFF;
    border-radius: 4px;
}

/* ========== 横向滑块QSlider ========== */
QSlider::groove:horizontal {
    height: 4px;
    background: #3E3E42;
    border-radius: 2px;
}

QSlider::handle:horizontal {
    background: #409EFF;
    width: 16px;
    height: 16px;
    margin: -6px 0;
    border-radius: 8px;
}

QSlider::handle:horizontal:hover {
    background: #66B1FF;
}

 

posted @ 2026-08-05 10:01  txwtech  阅读(14)  评论(0)    收藏  举报