[PyQt] Rich text in buttons

Baz Walter bazwal at ftml.net
Sat Nov 21 20:35:37 GMT 2009


Richard A. Litherland wrote:
> On Sat, 21 Nov 2009, Baz Walter wrote:
> 
>> Richard A. Litherland wrote:
>>> I'm very new to this, so I apologize if this question has been asked 
>>> 1000 times before. The text property of QAbstractButton doesn't 
>>> recognize HTML markup, but the developers of KCalc, at least, have 
>>> managed to work around this. I can't figure out how. Does anybody know?
>>
>> well, i suppose the kde developers do :)
>>
>> so why not have a look at the kcalc source code?
>>
>> http://api.kde.org/4.3-api/kdeutils-apidocs/kcalc/html/kcalc__button_8cpp_source.html 
>>
>>
> 
> I had, but was unable to find the relevant code. I've since discovered 
> that it's in an override of QPushButton's paintEvent method. Now all I 
> have to do is work out what's going on there... The author of the code 
> doesn't seem entirely happy with the amount of work needed, since he or 
> she includes the comment
> 
>   // rant: Qt4 needs QSimpleRichText, dammit!

there doesn't appear to be much kde-specific stuff in there, so 
hopefully you should be able to port it more-or-less as is. if you can't 
get it working, please post what you've got and i'm sure someone will 
try to help you further (or perhaps suggest some other way to achieve 
what you want).




More information about the PyQt mailing list