[Qt-interest] How to add a superscript text for any QAction item in QMenu
Girish Ramakrishnan
girish at forwardbias.in
Tue Apr 7 07:58:06 CEST 2009
Santhosh Y wrote:
> Girish Ramakrishnan wrote:
>> Santhosh Y wrote:
>>
>>> Arnold Krille wrote:
>>>
>>>> On Monday 06 April 2009 12:26:09 Santhosh Y wrote:
>>>>
>>>>
>>>>> I would like to add superscript text to a QMenu action's text.
>>>>>
>>>> If hypertext is supported inside QAction/QMenu (check by trying) you
>>>> can make your action-string "Action <sup>TM</sup>" or "<qt>Action
>>>> <sup>TM</sup></qt>". Or you can even search for the html-entity for
>>>> the raised TM...
>>>>
>>>> Arnold
>>>>
>>> Hi Arnold,
>>>
>>> Thanks for your suggestion.
>>>
>>> But when I tried this, the complete string being coming out including
>>> <sup> & </sup>.
>>>
>>> But I successfully printed out a message with QMessageBox in the
>>> following way:
>>> QMessageBox::critical(this,
>>> tr("Hardware report access failed"),
>>> tr("Hardware report cannot be viewed by <b>NORMAL</b>
>>> users"), QMessageBox::Ok);
>>>
>>> I am not able to understand why it is not working in Action's case.
>>>
>>
>> QMessageBox supports display rich text whereas QMenu does not.
>>
>> In your original question, you wanted a raised TM symbol - for that
>> particular case, you can just append the U+2122 unicode character.
>>
>> Girish
>>
> Hi Girish,
>
> Can you please tell me how to write the above unicode character, so
> that I can get in the menu action as I wanted.
>
> Can you please write few lines of code for doing the same
>
action->setText(QString("Foo%1").arg(QChar(0x2122)));
Grish
More information about the Qt-interest-old
mailing list