I'm currently working on some university project on Qgis and I have to use Python to generate maps.
I would like to know if there is a way to underline str (like shown on the screenshot).
Text rounded in red is the text I want to underline
Thank you in advance for your help !
CodePudding user response:
Indeed with QGIS it is particular... Maybe it exists other methods, but I do that:
First, you will have to separate the text to underline, and the other text.
Then use QtGui.QFont to custom your font, and apply it to the wanted text, instead the former setFont.
Example:
...
from PyQt5 import *
...
myTitleBoldFont=QtGui.QFont("Verdana", 27)
myTitleBoldFont.setUnderline(True)
...
TextCustom.setFont(myBoldFont)
Do not forget to import PyQt5.