Вопрос

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