[Interest] Interesting problem with properties.

Matthew Woehlke mw_triad at users.sourceforge.net
Wed May 27 23:36:45 CEST 2015


On 2015-05-27 17:23, Igor Mironchik wrote:
> 27.05.2015 23:41, Koehne Kai пишет:
>>> sendButton = new QtMWidgets::NavigationButton(
>>>            QtMWidgets::NavigationButton::Right, QObject::tr( "Send" ), q );
>>>
>>> First setText() invokes with "Send" text from constructor of
>>> NavigationButton, it's normal. But I have second invoke with "&Send".
>>>
>>> What is the problem can be?
>>
>> This is most likely then the KDEPlatformTheme plugin messing with your texts.
>>
>> See e.g. https://bugs.kde.org/show_bug.cgi?id=337491 . It doesn't seem like KDE considers this a problem ...
> 
> Thank you. Now I can sleep peacefully :)
> 
> But that  KDE doesn't consider this a problem is a problem :)
> 
> It's seems that I have to implement more smart painting and hide this 
> "&" sign...

No... well, depending on what you mean by "smart". If you are doing
custom text painting for a widget, you should be handling the '&' as an
accelerator indicator (which is what it is). Note that there is logic in
QPainter::drawText() to do this for you. In particular, see the
Qt::TextShowMnemonic flag. (Exact methods may vary if you are drawing
via QStyle, but you should still be able to tell whatever you are using
to paint to render mnemonics / accelerator indicators as such.)

If you are rolling your own text rendering, then yes, you should
explicitly ignore the character yourself :-), or better, paint it
properly. (If you think you might need to care, note that "&&" should be
rendered as a single '&'.)

-- 
Matthew




More information about the Interest mailing list