I am using PyQt5 on Python 3.5.
I want to make a QLabel
widget with a centered text. Therefore, I call the setAlignment
method with the AlignCenter
flag.
Here is an MWE:
import sys
from PyQt5 import QtWidgets, Qt
app = QtWidgets.QApplication(sys.argv)
label = QtWidgets.QLabel()
label.setAlignment(Qt.AlignCenter)
However, I get the following error:
label.setAlignment(Qt.AlignCenter)
AttributeError: module 'PyQt5.Qt' has no attribute 'AlignCenter'
But the Qt.AlignCenter
, as well as other alignment flags, are referenced in PyQt's documentation, as well as Qt's documentation.
What am I doing wrong?