我在QTreeView的行中有一些QPushButtons,它们周围出现了这些黑色边框,我似乎无法修改.目前我可以使用以下代码将按钮变灰:
for (int i = 0; i < QPalette::NColorRoles; i++){
QPalette::ColorRole thisRole = static_cast<QPalette::ColorRole>(i);
QColor newColor = commitPalette.color(QPalette::Disabled,thisRole);
int grayColor = qGray(newColor.rgb());
newColor.setRgb(grayColor,grayColor,grayColor,50);
commitPalette.setColor(QPalette::Disabled, thisRole, newColor);
}
Run Code Online (Sandbox Code Playgroud)
但它对边界没有任何作用.我更喜欢避免使用样式表,因为我喜欢QPalette的构造函数提供的自动颜色生成
