CWI*_*MER 2 checkbox stylesheet indicator qcombobox qtstylesheets
程序员
当我设置属于QComboBox(每个 QSS)的列表视图的背景颜色时,这个 QComboBox 将不再使用内置的光学外观。Instaed 我还必须为每个 QSS 样式表指定所有光学设置:
QComboBox QListView {
background-color:white;
border:1px solid black;
}
Run Code Online (Sandbox Code Playgroud)
显示可选项的列表视图现在在左侧显示一个复选框。为那些在上次使用时选择的项目选中此框。
如何隐藏带有复选框的列,以便它们不可见并且不会占用屏幕上的任何空间?
提前致谢...
QComboBox 困难绘图主题的 QSS 解决方法
如果您不使用 QSS 块,则 QComboBox 将以其 OS-Look-and-Feel 绘制。如果您开始指定 QSS 规则,则 QComboBox 的部分或所有子控件开始失去 OS-Look-and-Feel。在最坏的情况下,您现在必须在 QSS 中指定所有属性。
本文的主题是由 QStyleViewItem 类绘制的选择指示器,该类是在 QT 源中的 .../src/gui/widgets/qcombobox_p.h 中实现的渲染助手。这个功能似乎不可能被 QProxyStyle 的子类修改,它可以在其他情况下用于解决硬布局问题。
但是,我通过指定一组精心挑选的规则在 QSS 中找到了解决方案:
/* Background color of popup-list.*/
QComboBox QListView{
background-color:white;
border:1px solid gray;
}
/* Needed to complete the rule set. */
QComboBox::item:alternate {
background: white;
}
/* Color of the selected list item. */
QComboBox::item:selected {
border: 1px solid transparent;
background:yellow;
}
/* Indicator will shine through the label text if you don't make it hidden. */
QComboBox::indicator{
background-color:transparent;
selection-background-color:transparent;
color:transparent;
selection-color:transparent;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2744 次 |
| 最近记录: |