Qt 除非元素处于悬停状态,否则复选框中的选中符号不可见
在一个Qt应用程序中,我有一个按钮,稍后用一些代码将一个菜单附加到该按钮上。菜单的每个元素都是可检查的Qt 除非元素处于悬停状态,否则复选框中的选中符号不可见,qt,qt4,pyside,Qt,Qt4,Pyside,在一个Qt应用程序中,我有一个按钮,稍后用一些代码将一个菜单附加到该按钮上。菜单的每个元素都是可检查的QAction。有趣的是,一旦元素被选中,复选标记就不可见,除非你用鼠标悬停它。以下是一个屏幕截图: 我有一些定制的QCS集,但是,我从未为QAction或任何东西添加过任何样式,如下所示: QMainWindow, QDialog { background: #E8E8E8; color: #2e2e2e; } QMenuBar, QStatusBar { background:
QAction
。有趣的是,一旦元素被选中,复选标记就不可见,除非你用鼠标悬停它。以下是一个屏幕截图:
我有一些定制的QCS集,但是,我从未为QAction
或任何东西添加过任何样式,如下所示:
QMainWindow, QDialog { background: #E8E8E8; color: #2e2e2e; }
QMenuBar, QStatusBar {
background: #545454;
color: #fff;
}
QLabel#lblBanner {
background: qlineargradient(x1: 0, y1: 0.01, x2: 0, y2: 1,
stop: 0 #545454, stop: 1 #141414);
margin: 0;
}
QMenu {
background: #E8E8E8;
}
QMenuBar::item {
background: transparent;
}
QMenuBar::item:selected {
background: #444442;
border: 0;
}
QMenuBar::item:pressed {
background: #444442;
}
QMenu::item:selected {
background: #cfcfcf;
}
QGroupBox {
background: #fff;
/* border: 1px solid white; */
border-radius: 5px;
margin: 3px 3px 3px 3px;
padding: 18px 5px 10px 5px;
font-weight: bold;
}
QGroupBox::title {
subcontrol-origin: margin;
subcontrol-position: top left;
color: black;
font-style: bold;
/* padding: 4px 5px; */
margin-left: 6px;
margin-top: 7px;
background: transparent;
color: #2e2e2e;
}
QPushButton, QDialogButtonBox {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #f5f5f5, stop: 1 #cfcfcf);
border-radius: 3px;
padding: 5px 10px;
margin: 1px;
min-width: 30px ;
}
QPushButton:hover, QDialogButtonBox:hover {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #cfcfcf, stop: 1 #b5b5b5);
}
QPushButton:pressed, QDialogButtonBox:pressed {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #b5b5b5, stop: 1 #cfcfcf);
}
QPushButton:default, QDialogButtonBox:default {
border: 1px solid;
border-color: orange; /* make the default button prominent */
}
QPushButton[enabled=false]
{
background: #ededed;
color: #cfcfcf;
}
QLineEdit, QTextEdit {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.3,
stop: 0 #f2f2f2, stop: 1 white);
border: 2px solid #E8E8E8;
selection-background-color: orange;
border-radius: 5px;
padding: 3px;
}
QHeaderView::section {
background-color: qlineargradient(x1: 0, y1: 0.01, x2: 0, y2: 1,
stop: 0 #545454, stop: 1 #141414);
color: white;
padding-left: 10px;
border: 1px solid #6c6c6c;
}
QTreeWidget {
border: 2px solid #E8E8E8;
border-radius: 5px;
selection-background-color: orange;
show-decoration-selected: 1;
}
/* QTreeWidget::item:selected { */
/* background: ; */
/* } */
QTreeWidget::item:selected:!active {
background: #e59500;
}
QTreeWidget::item:selected:active {
background: #f29d00;
}
QTreeWidget::item:hover {
background: orange;
}
QTreeWidget::branch {
background: white;
}
/* barra de desplazamiento */
/* Vertical */
QScrollBar:vertical {
background: #fff;
width: 10px;
}
QScrollBar::handle:vertical {
background: #E8E8E8;
}
/* Horizontal */
QScrollBar:horizontal {
background: #fff;
height: 10px;
}
QScrollBar::handle:horizontal {
background: #E8E8E8;
}
/* Fin de la barra de desplazamiento */
QProgressBar {
border: 2px solid orange;
border-radius: 5px;
background: #fff;
text-align: center;
}
QProgressBar::chunk {
background: orange;
margin: 2px;
border-radius: 5px;
}
问题可能是什么?我可以用什么方法解决这个问题?尝试以下方法:
QMenu::indicator:checked
{
image: url(:/icons/checkbox_checked);
}
有时,指定某些QSS元素会否定对操作系统默认值的依赖,您必须自己指定所有内容。如果删除自定义CSS,您是否仍有问题?@tmoreau根本没有!那会是什么?@tmoreau啊!如果指定了
QMenu{background:#E8E8E8;}
,则会发生此问题!