Search code examples
pythonpyqtpyqt5superscriptqspinbox

How to use superscripts in QDoubleSpinBox suffix


I am trying to format part of a suffix in a QDoubleSpinBox as a superscript. Thus far I have tried the following:

self.myDblSinBox.setSuffix("Nsm<sup>-4</sup>")

and:

self.myDblSinBox.setSuffix(r"Nsm$^{-4}$")

but without succes. Is there anyone who knows if this is possible? I am using Python 3.6, IPython 6.1, Spyder 3.2.3, and PyQt5.


Solution

  • You can use unicode superscript characters for this:

    self.myDblSinBoxsetSuffix(' Nsm\u207b\u2074')
    

    enter image description here