سؤال

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