简体   繁体   English

如何在 QDateTimeEdit 中更改字体颜色

[英]How to change font color in QDateTimeEdit

I use QDateTimeEdit widget and QCheckBox.我使用 QDateTimeEdit 小部件和 QCheckBox。 I want to change color of QDateTimeEdit's font depends whether checkbox is selected.我想改变 QDateTimeEdit 字体的颜色取决于是否选中了复选框。 I can't find function to set font color.我找不到 function 来设置字体颜色。

If you want to change the color of the text there are the following options depending on the style you use:如果要更改文本的颜色,则根据您使用的样式有以下选项:

QPalette pal = w.palette();
pal.setColor(QPalette::Text, QColor("#00ff00"));
w.setPalette(pal)

Or或者

w.setStyleSheet("color: #00ff00");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM