문제

I would like to know if there is an effective way to center the title into the form, I put mtitle.move but it's not easy to find the center by trial and error. If anybody can help me I'll appreciate that.

mtitle = QtGui.QLabel('GB DATABASE', self)
mtitle.setStyleSheet("font: bold 50pt AGENTORANGE") 
mtitle.resize(720, 80)
mtitle.move(200, 10)
도움이 되었습니까?

해결책

Try the following:

from PyQt import QtCore
mtitle.setAlignment(QtCore.Qt.AlignCenter)

(Note: Centering the Label-Widget inside it's parent widget can be done using QT's Layouts (standard method) or using this approach

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