[PyQt] QLabel setFont does not work

Linos info at linos.es
Thu Nov 8 09:19:38 GMT 2007


Hello all,
	i have a problem with a QLabel i want to change the font size and make bold, i have a dialog created in
designer where i have changed the font, i can view the change ok in the designer preview but when i launch the
code with the dialog imported it doest not change the standard font, i cant set from code either i have tried
this:

print self.totalCuentaLabel.font().toString()
font = QFont("Sans Serif", 12, QFont.Bold)
self.totalCuentaLabel.setFont(font)
self.totalCuentaLabel.update()
print self.totalCuentaLabel.font().toString()
self.totalCuentaLabel.setText(QString("TOTAL CUENTA:"))
font = QFont("Sans Serif", 12, QFont.Bold)
self.totalCuentaLabel.setFont(font)
print self.totalCuentaLabel.font().toString()

and i get this output:

>>> Times New Roman,12,-1,5,75,0,0,0,0,0
Sans Serif,12,-1,5,75,0,0,0,0,0
Sans Serif,12,-1,5,75,0,0,0,0,0

the first font it is from designer but it does not work either. i ever view in the dialog my standard qlabel
font "Sans Serif,9", anyone know how to fix this? Thanks in advance.


More information about the PyQt mailing list