문제

I wrote the following code but when I run the program only appears two letters of the main title. Anybody knows how to fix it?

class Window(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
    #self.center()
    self.setStyleSheet("background-color: white")
    self.resize(1028, 720)
    self.setWindowTitle('GBLtda Database')
    label = QtGui.QLabel('GB DATABASE', self)
    label.setStyleSheet("font: 50pt AGENTORANGE") 
        label.move(20, 20)
도움이 되었습니까?

해결책 2

Try this:

label.resize(514, 360)

The first is the width in pixels, and the second is the height - you want the height to be at least 10% more than the font size, so 55 is the minimum number for that. (obviously, change the values to suit what you like)

다른 팁

Becase the label widgets does not resize.

You need to resize it using resize method after changing font.

...
label.setStyleSheet("font: 50pt AGENTORANGE") 
label.resize(label.sizeHint()) # <-----
label.move(20, 20)

Or, you can put the label inside the layout object.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top