在Qt应用程序中,我有一个按钮,稍后我会在其中添加一些菜单。菜单的每个元素都是可检查的QAction
。有趣的是,一旦元素被检查,检查符号就不可见,除非你用鼠标悬停它。这是一个截图:
我有一些自定义QCSS集,但是,我从未为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;
}
或其他任何内容添加任何样式,这里是:
sprintf(array,"%f\0",floatvar);
可能是什么问题以及我可以通过哪种方式解决这个问题?
答案 0 :(得分:1)
尝试这样的事情:
QMenu::indicator:checked
{
image: url(:/icons/checkbox_checked);
}
有时指定某些 QSS元素会拒绝依赖操作系统默认值,您必须自己指定所有内容。