本文介绍了QPushButton 中的两种颜色文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
我需要一个文本中有两种颜色的 QPushButton.我在 QTextDocument 中找到了一个带有 html 代码的解决方案,并且它正在运行.但是我需要居中对齐并且 html 代码不起作用.
I need a QPushButton with two colors in the text. I found a solution with a html code in QTextDocument and it's working. But I need center align and the html code isn't working.
我明白了,
相同的代码 HTML 在 QLabel 中工作
The same code HTML is working in a QLabel
有什么解决办法吗?
非常感谢.
推荐答案
你可以从QPushButton派生出来,通过paintEvent中的QPainter自己绘制文本.
You can derive from QPushButton and draw text yourself via QPainter in paintEvent.
这篇关于QPushButton 中的两种颜色文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!