设置纯色背景
setPalette(QPalette(QColor(1,1,255)));
设置渐变背景色
setStyleSheet("background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #8386ec,stop:0.5 #474ac1 ,stop:1 #22259f)");
这篇博客介绍了如何使用QPalette和setStyleSheet为界面设置纯色和渐变背景。通过QPalette可以方便地设定控件的纯色背景,而setStyleSheet则支持更复杂的CSS样式,如线性渐变背景。示例代码展示了从浅蓝到深蓝的垂直渐变背景效果。
设置纯色背景
setPalette(QPalette(QColor(1,1,255)));
设置渐变背景色
setStyleSheet("background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #8386ec,stop:0.5 #474ac1 ,stop:1 #22259f)");
2万+
1055
2669
3102
2056

被折叠的 条评论
为什么被折叠?