Search code examples
c++qtqwidgetqtguiqcombobox

How to display superscript in QComboBox item?


I want to display 10-8 in QComboBox item. But it displays "sup" tags.


Solution

  • the easiest way is to use special Unicode characters and use them in translation file (direct usage in code may be problematic):

    10⁻⁸

    If you don't like use translation file try this code:

    ui->comboBox->addItem(QString::fromWCharArray(L"10\x207B\x2078"));
    ui->comboBox->addItem(QString::fromWCharArray(L"10⁻⁸"));
    

    On my Qt.5.2.1 (Linux) it works. Also pasting above string in designer also works.