Why CSS of QWidget fail in QScrollArea?



  • alt text
    I use qApp->setStyleSheet to set style sheet for all widgets in the initialization, but I find that the widgets which in the QScrollArea lost the effect of the style sheet(the upper QPushButton). The following QPushButton which is I want. I can't find the reason, can you help me?Thanks very much!


  • Qt Champions 2016

    @jinzhu1912
    Hi
    Maybe show your style sheet?
    There is no reason it should not work in scrollarea so something else is wrong :)



    • {color: #eeeeee; font-family: "微软雅黑"; font-size: 16px; }

    QWidget:focus { outline: none; }

    QAbstractItemView { background: transparent; }

    QCheckBox:disabled { color: #a0b3bb; background: transparent; }
    QCheckBox:indicator, QHeaderView:indicator, QGroupBox:indicator, QListView:indicator, QTableView:indicator, QTreeView:indicator { width: 13; height: 13; }
    QCheckBox:indicator:unchecked, QHeaderView:indicator:unchecked, QGroupBox:indicator:unchecked, QListView:indicator:unchecked, QTableView:indicator:unchecked, QTreeView:indicator:unchecked { image: url("../Data/Img/darkBlue/QCheckBox/typeOne/unchecked_normal.png"); }
    QCheckBox:indicator:unchecked:hover, QHeaderView:indicator:unchecked:hover, QGroupBox:indicator:unchecked:hover, QListView:indicator:unchecked:hover, QTableView:indicator:unchecked:hover, QTreeView:indicator:unchecked:hover { image: url("../Data/Img/darkBlue/QCheckBox/typeOne/unchecked_hover.png"); }
    QCheckBox:indicator:unchecked:pressed, QHeaderView:indicator:unchecked:pressed, QGroupBox:indicator:unchecked:pressed, QListView:indicator:unchecked:pressed, QTableView:indicator:unchecked:pressed, QTreeView:indicator:unchecked:pressed { image: url("../Data/Img/darkBlue/QCheckBox/typeOne/unchecked_pressed.png"); }
    QCheckBox:indicator:unchecked:disabled, QHeaderView:indicator:unchecked:disabled, QGroupBox:indicator:unchecked:disabled, QListView:indicator:unchecked:disabled, QTableView:indicator:unchecked:disabled, QTreeView:indicator:unchecked:disabled { image: url("../Data/Img/darkBlue/QCheckBox/typeOne/unchecked_disabled.png"); }
    QCheckBox:indicator:checked, QHeaderView:indicator:checked, QGroupBox:indicator:checked, QListView:indicator:checked, QTableView:indicator:checked, QTreeView:indicator:checked { image: url("../Data/Img/darkBlue/QCheckBox/typeOne/checked_normal.png"); }
    QCheckBox:indicator:checked:hover, QHeaderView:indicator:checked:hover, QGroupBox:indicator:checked:hover, QListView:indicator:checked:hover, QTableView:indicator:checked:hover, QTreeView:indicator:checked:hover { image: url("../Data/Img/darkBlue/QCheckBox/typeOne/checked_hover.png"); }
    QCheckBox:indicator:checked:pressed, QHeaderView:indicator:checked:pressed, QGroupBox:indicator:checked:pressed, QListView:indicator:checked:pressed, QTableView:indicator:checked:pressed, QTreeView:indicator:checked:pressed { image: url("../Data/Img/darkBlue/QCheckBox/typeOne/checked_pressed.png"); }
    QCheckBox:indicator:checked:disabled, QHeaderView:indicator:checked:disabled, QGroupBox:indicator:checked:disabled, QListView:indicator:checked:disabled, QTableView:indicator:checked:disabled, QTreeView:indicator:checked:disabled { image: url("../Data/Img/darkBlue/QCheckBox/typeOne/checked_disabled.png"); }

    QPlainTextEdit, QTextEdit { padding: 0 5; }
    QComboBox, QDateEdit, QDateTimeEdit, QDoubleSpinBox, QLineEdit, QSpinBox, QTimeEdit { min-height: 24; max-height: 24; padding: 0 5; }
    QComboBox:editable, QDateEdit, QDateTimeEdit, QDoubleSpinBox, QLineEdit, QPlainTextEdit, QSpinBox, QTextEdit, QTimeEdit { border: 1 solid #3e769c; background-color: rgba(10, 30, 52, 80%); }
    QComboBox:editable:focus, QDateEdit:focus, QDateTimeEdit:focus, QDoubleSpinBox:focus, QLineEdit:focus, QPlainTextEdit:focus, QSpinBox:focus, QTextEdit:focus, QTimeEdit:focus { border: 1 solid #5ec5df; background-color: rgba(10, 30, 52, 80%); }
    QComboBox, QDateEdit:read-only, QDateTimeEdit:read-only, QDoubleSpinBox:read-only, QLineEdit:read-only, QPlainTextEdit:read-only, QSpinBox:read-only, QTextEdit:read-only, QTimeEdit:read-only { border: 1 solid #3e769c ; background-color: rgba(32, 54, 78, 60%); }
    QComboBox:disabled, QDateEdit:disabled, QDateTimeEdit:disabled, QDoubleSpinBox:disabled, QLineEdit:disabled, QPlainTextEdit:disabled, QSpinBox:disabled, QTextEdit:disabled, QTimeEdit:disabled { border: 1 solid #646464; background-color: rgba(113, 113, 113, 60%); color: #a0b3bb; }

    QComboBox:!editable:!disabled { border-image: url("../Data/Img/darkBlue/QComboBox/typeOne/light_normal.png"); }
    QComboBox:!editable:!disabled:hover { border-image: url("../Data/Img/darkBlue/QComboBox/typeOne/light_hover.png"); }
    QComboBox::drop-down { min-width: 22; max-width: 22; min-height: 22; max-height: 22; padding-top: 1;}
    QComboBox::drop-down { border-image: url("../Data/Img/darkBlue/QComboBox/typeOne/normal.png"); }
    QComboBox::drop-down:hover { border-image: url("../Data/Img/darkBlue/QComboBox/typeOne/hover.png"); }
    QComboBox::drop-down:on { border-image: url("../Data/Img/darkBlue/QComboBox/typeOne/on.png"); }
    QComboBox QAbstractItemView { color: #eeeeee; border: 1 solid #3e769c; background-color: rgba(10, 30, 52, 80%); selection-background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2:1, stop: 0 rgba(44, 69, 99, 200), stop: 1 rgba(73, 110, 146, 200)); }

    QDateEdit::up-button, QDateEdit::down-button, QDateTimeEdit::up-button, QDateTimeEdit::down-button, QDoubleSpinBox::up-button, QDoubleSpinBox::down-button, QSpinBox::up-button, QSpinBox::down-button, QTimeEdit::up-button, QTimeEdit::down-button { min-width: 22; max-width: 22; }
    QDateEdit::up-button, QDateTimeEdit::up-button, QDoubleSpinBox::up-button, QSpinBox::up-button, QTimeEdit::up-button { min-height: 12; max-height: 12; }
    QDateEdit::down-button, QDateTimeEdit::down-button, QDoubleSpinBox::down-button, QSpinBox::down-button, QTimeEdit::down-button { min-height: 10; max-height: 10; }
    QDateEdit::up-button, QDateTimeEdit::up-button, QDoubleSpinBox::up-button, QSpinBox::up-button, QTimeEdit::up-button { border-image: url("../Data/Img/darkBlue/QSpinBox/typeOne/up_normal.png"); }
    QDateEdit::down-button, QDateTimeEdit::down-button, QDoubleSpinBox::down-button, QSpinBox::down-button, QTimeEdit::down-button { border-image: url("../Data/Img/darkBlue/QSpinBox/typeOne/down_normal.png"); }
    QDateEdit::up-button:hover, QDateTimeEdit::up-button:hover, QDoubleSpinBox::up-button:hover, QSpinBox::up-button:hover, QTimeEdit::up-button:hover { border-image: url("../Data/Img/darkBlue/QSpinBox/typeOne/up_hover.png"); }
    QDateEdit::down-button:hover, QDateTimeEdit::down-button:hover, QDoubleSpinBox::down-button:hover, QSpinBox::down-button:hover, QTimeEdit::down-button:hover { border-image: url("../Data/Img/darkBlue/QSpinBox/typeOne/down_hover.png"); }
    QDateEdit::up-button:pressed, QDateTimeEdit::up-button:pressed, QDoubleSpinBox::up-button:pressed, QSpinBox::up-button:pressed, QTimeEdit::up-button:pressed { border-image: url("../Data/Img/darkBlue/QSpinBox/typeOne/up_pressed.png"); }
    QDateEdit::down-button:pressed, QDateTimeEdit::down-button:pressed, QDoubleSpinBox::down-button:pressed, QSpinBox::down-button:pressed, QTimeEdit::down-button:pressed { border-image: url("../Data/Img/darkBlue/QSpinBox/typeOne/down_pressed.png"); }
    QDateEdit::up-button:disabled, QDateTimeEdit::up-button:disabled, QDoubleSpinBox::up-button:disabled, QSpinBox::up-button:disabled, QTimeEdit::up-button:disabled { border-image: url("../Data/Img/darkBlue/QSpinBox/typeOne/up_disabled.png"); }
    QDateEdit::down-button:disabled, QDateTimeEdit::down-button:disabled, QDoubleSpinBox::down-button:disabled, QSpinBox::down-button:disabled, QTimeEdit::down-button:disabled { border-image: url("../Data/Img/darkBlue/QSpinBox/typeOne/down_disabled.png"); }

    QFrame[type="typeOne"][line="VLine"] { width: 2; border: none; border-image: url("../Data/Img/darkBlue/QFrame/typeOne/VLine.png"); }
    QFrame[type="typeTwo"][line="VLine"] { width: 2; border: none; border-image: url("../Data/Img/darkBlue/QFrame/typeTwo/VLine.png"); }
    QFrame[type="typeOne"][line="HLine"] { height: 2; border: none; border-image: url("../Data/Img/darkBlue/QFrame/typeOne/HLine.png"); }
    QFrame[type="typeTwo"][line="HLine"] { height: 2; border: none; border-image: url("../Data/Img/darkBlue/QFrame/typeTwo/HLine.png"); }

    QGroupBox { background-color: rgba(16, 84, 120, 40%); border: 1 solid #32b16c; margin-top: 8; padding-top: 2px; }
    QGroupBox[title=""] { margin: 0; }
    QGroupBox::title { subcontrol-origin: margin; margin-left: 5; margin-right: 5; left: 15; top: -3; }
    QGroupBox::title:disabled{ background: gray; }
    QGroupBox:disabled { color: #a0b3bb; border-color: gray; }

    QGroupBox[checkable="true"]::title { top: -2; }

    QGroupBox[type="typeOne"] { margin: 0; border-top-width: 42; border-right-width: 4; border-left-width: 120; border-bottom-width: 4; padding: 0 2 2 -114; }
    QGroupBox[type="typeOne"] { border-image: url("../Data/Img/darkBlue/QGroupBox/typeOne/bg.png") 42 4 4 120; }
    QGroupBox[type="typeOne"]::title { subcontrol-origin: margin; subcontrol-position: top left; background: transparent; border: none; min-height: 36; max-height: 36; left: 20; top: 0;}
    QGroupBox[type="typeOne"]::title { border-image: url("../Data/Img/darkBlue/QGroupBox/typeOne/title_text_bg.png"); }

    QGroupBox[type="typeThree"] { border: 1 solid #32b16c; margin: 0; padding: 0; }

    QHeaderView { border-image: url("../Data/Img/darkBlue/QHeaderView/typeOne/bg.png") 2; border-width: 2; padding: -2; }
    QHeaderView::section { border-style: solid; border-width: 0 1; border-right-color: rgba(14, 66, 122, 40%); border-left-color: rgba(108, 189, 226, 40%); background: transparent; min-height: 24; }
    QHeaderView::section:hover { background-image: url("../Data/Img/darkBlue/QHeaderView/typeOne/section_hover.png") 2; }
    QHeaderView::section:checked { background-image:url("../Data/Img/darkBlue/QHeaderView/typeOne/section_selected.png") 2;}

    QHeaderView::up-arrow { width: 13; height: 13; image: url("../Data/Img/darkBlue/QHeaderView/typeOne/up_normal.png"); image-position: right; }
    QHeaderView::up-arrow:hover { image: url("../Data/Img/darkBlue/QHeaderView/typeOne/up_hover.png"); }
    QHeaderView::down-arrow { width: 13; height: 13; image: url("../Data/Img/darkBlue/QHeaderView/typeOne/down_normal.png"); image-position: right; }
    QHeaderView::down-arrow:hover { image: url("../Data/Img/darkBlue/QHeaderView/typeOne/down_hover.png"); }

    QListView, QTableView, QTreeView { background-color: rgba(23, 49, 74, 60%); alternate-background-color: rgba(34, 60, 87, 60%); border: 1 solid #4c84af; show-decoration-selected: 1; }
    QListView::item, QTableView::item, QTreeView::item { height: 25; padding: 0 7; }
    QListView::item:hover, QTableView::item:hover, QTreeView::item:hover { border-image: url("../Data/Img/darkBlue/QTableView/typeOne/hover.png"); }
    QListView::item:selected, QTableView::item:selected, QTreeView::item:selected { border-image: url("../Data/Img/darkBlue/QTableView/typeOne/selected.png"); }
    QListView::item:selected:!focus, QTableView::item:selected:!focus, QTreeView::item:selected:!focus { color: #eeeeee; }

    QMenu { border: 1 solid #4c84af; background-color: #11273f; }
    QMenu::item { padding:2 25 2 20; height: 25; }
    QMenu::item:selected { border-image: url("../Data/Img/darkBlue/QMenu/typeOne/selected.png") 2; border: 2; }
    QMenu::separator { height: 2; border-image: url("../Data/Img/darkBlue/QFrame/typeOne/HLine.png"); }

    QMenuBar { border: none; min-height: 32; border-image: url("../Data/Img/darkBlue/QMenuBar/typeOne/bg.png") 2; border-width: 2; font-size: 18px; padding-left: 40; }
    QMenuBar::item:disabled { color: #a0b3bb; }
    QMenuBar::item { background: transparent; padding: 0 25; }
    QMenuBar::item:selected { border-image: url("../Data/Img/darkBlue/QMenuBar/typeOne/selected.png"); }
    QMenuBar::item:pressed { border-image: url("../Data/Img/darkBlue/QMenuBar/typeOne/pressed.png"); }

    QPushButton, QPushButton[type="typeOne"], QPushButton[type="typeTwo"] { height: 24; min-width: 56; border-width: 5; padding: -5 2; }
    QPushButton, QPushButton[type="typeOne"]{ border-image: url("../Data/Img/darkBlue/QPushButton/typeOne/normal.png") 5; }
    QPushButton:hover, QPushButton[type="typeOne"]:hover { border-image: url("../Data/Img/darkBlue/QPushButton/typeOne/hover.png") 5; }
    QPushButton:pressed, QPushButton[type="typeOne"]:pressed { border-image: url("../Data/Img/darkBlue/QPushButton/typeOne/pressed.png") 5; }
    QPushButton::checked , QPushButton[type="typeOne"]::checked { border-image: url("../Data/Img/darkBlue/QPushButton/typeOne/checked.png") 5; color: #ffaa00; }
    QPushButton:disabled { color: #a0b3bb; background: transparent; }
    QPushButton:disabled, QPushButton[type="typeOne"]:disabled { border-image: url("../Data/Img/darkBlue/QPushButton/typeOne/disabled.png") 5; }

    QPushButton[type="typeTwo"] { border-width: 5 6 5 6; }
    QPushButton[type="typeTwo"] { border-image: url("../Data/Img/darkBlue/QPushButton/typeTwo/normal.png") 5 6 5 6; }
    QPushButton[type="typeTwo"]:hover { border-image: url("../Data/Img/darkBlue/QPushButton/typeTwo/hover.png") 5 6 5 6; }
    QPushButton[type="typeTwo"]:pressed { border-image: url("../Data/Img/darkBlue/QPushButton/typeTwo/pressed.png") 5 6 5 6; }
    QPushButton[type="typeTwo"]:disabled { border-image: url("../Data/Img/darkBlue/QPushButton/typeTwo/disabled.png") 5 6 5 6; }

    QProgressBar { border-width: 3; min-height: 20; max-height: 20; min-width: 20; text-align: center; }
    QProgressBar { border-image: url("../Data/Img/darkBlue/QProgressBar/typeOne/bar.png") 3;}
    QProgressBar::chunk { border-image: url("../Data/Img/darkBlue/QProgressBar/typeOne/chunk.png") 2; border-width: 2; spacing: 2;}


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.