如何更改Qcombobox向下箭头图像? 现在我正在使用这个QSS代码,但这不起作用,我无法删除箭头边框。
QComboBox
{
border: 0px;
}
QComboBox::down-arrow
{
border: 0px;
background-repeat: no-repeat;
background-position: center center;
background-image-width: 50px;
border-image: url(./select-BG.png);
heidth:50px;
width:100px;
}
以下是截图:
答案 0 :(得分:5)
这是一个相当晚的答案,但我认为我在Qt论坛的某个地方找到了解决方案。
将边框设置为0px时,似乎替换了组合框箭头的整个样式。因此,我使用QComboBox::drop-down
将边框设置为0x,然后使用QComboBox::down-arrow
定义自定义箭头。下面的代码显示了一个奇怪错误的额外修复,其中无法正确更改文本的color
属性。
QComboBox {
color: black;
font: 14px;
padding: 1px 0px 1px 3px; /* This (useless) line resolves a bug with the font color */
}
QComboBox:focus {
color: red;
}
QComboBox::drop-down
{
border: 0px; /* This seems to replace the whole arrow of the combo box */
}
/* Define a new custom arrow icon for the combo box */
QComboBox::down-arrow {
image: url(Resources/DropDownArrow.png);
width: 14px;
height: 14px;
}
我希望有人可以使用此信息并使其正常工作: - )
答案 1 :(得分:1)
箭头位于按钮上,其样式由::drop-down
子控件控制。因此,要删除边框,您可以使用:
QComboBox::drop-down
{
border: 0px;
}