سؤال

I'm a beginner in Pyqt and I made the main form but I don't know how to modify the size and the type of the font in the Qlabel?

def __init__(self):
    QtGui.QMainWindow.__init__(self)
    self.center()
    self.setWindowTitle('GBLtda Database')
    self.setStyleSheet("background-color: white")
    self.resize(1028, 720)
    label = QtGui.QLabel('GB DATABASE', self)
    label.move(15, 10)
    self.setWindowIcon(QtGui.QIcon('db.png'))  
هل كانت مفيدة؟

المحلول

Using stylesheets:

#for the whole widget   
self.setStyleSheet("QLabel {font: 30pt Comic Sans MS}")
#Just for this label
label.setStyleSheet("font: 30pt Comic Sans MS")

نصائح أخرى

The simplest way is to set the font using setFont(QFont) method.

label.setFont(QFont('Arial', 20))

Since it inherits from QWidget I guess you should be able to apply a stylesheet via member .setStyleSheet?

i.e.: http://qt.developpez.com/doc/4.7-snapshot/stylesheet-examples/

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top