can explain that the function arguments should take
setalignment= none, qt_alignmentflag= none):
in advance Thank you.
Answer # 1
Let's look at the method description
# Real Signature Unknown; Restored from __doc__ def setalignment (Self, Union, QT_ALIGNMENT= NONE, QT_ALIGNMENTFLAG= NONE): "" "SETATIGNMENT (SELF, UNION [QT.ALIGNMENT, QT.alignmentFlag])" "" Pass
It shows that the real signature described in
__doc__has one parameter (this is confirmed when trying to transfer more than one parameter to the function), which either
Union, QT_ALIGNMENT= NONE, QT_ALIGNMENTFLAG= NONEIn fact, this is one parameter.
Additional confirmation can be seen if you see Description of the same method in the documentation of Qt itself:
Void SetAlignment (Qt :: Alignment)
And then the question may arise:
why in pyqt5 this parameter is described as Union [Qt.alignment, Qt.alignmentFlag], and in the original documentation just Qt :: Alignment?
To answer the question, you also need to look at the Qt documentation for the listing Qt :: Alignment:
Enum Qt :: AlignmentFlag Flags. Qt :: Alignment
Qt :: AlignmentThis is a set of flags
Qt :: AlignmentFlag:
Qt :: Alignleft..
Qt :: alignrightetc., in other words in
Qt :: Alignmentcan transmit a specific flag or several minutes at once: for example, the flag
Qt :: Aligncenter.Built from flags
Qt :: AlignVcenter.and
Qt :: Alignhcenter..
To make a list of flags need to be listed through a bit
My_align_Center= Qt :: AlignVCenter | Qt :: Alignhcenter.
Union [Qt.alignment, Qt.alignmentFlag]This is an indication of one of the listed variations in the parameter, which converges with the fact that he wrote above.
I explained why it is indicated
Union [Qt.alignment, Qt.alignmentFlag]in the description of the parameter
Now, a little practice.
from pyqt5.Qtwidgets import QLabel, Qapplication, QGridlayout, QWidget from pyqt5.Qtcore Import Qt DEF CREATE_LABEL (ALIGNMENT): Label= QLabel ('Test') label.setfixedsize (40, 40) label.setframestyle (QLabel.Box) label.setAlignment (Alignment) Return Label App= Qapplication () layout= qgridlayout () layout.addwidget (Create_Label (Qt.alignleft), 0, 0) layout.addwidget (Create_Label (Qt.alignleft | Qt.alignBottom), 0, 1) layout.addwidget (Create_Label (Qt.alignleft | Qt.alignVCenter), 0, 2) layout.addwidget (Create_Label (Qt.alignleft | Qt.aligntop), 0, 3) layout.addwidget (Create_Label (Qt.alignhCenter | Qt.aligntop), 0, 4) layout.addwidget (Create_Label (Qt.alignRight | Qt.alignVCenter), 0, 5) w= qwidget () W.Setlayout (Layout) w.show () app.exec ()
- python : Pyqt5 Print HTML Documents
- How to set the pyqt5 container width? (Python3)
- python : Why doesn't Qtimer work? (Part 2)
- python : How to make the button expandable by pressing the widget in PyQT5?
- python : Hangs the application (pyqt + socket)
- python : Lack of some methods in Qtcore -PyQT5
- python : Pyqt5 color animation widget
- python : Track the cursor position in pyqtgraph
- python : How can you move toolbar in the window?
- python : PyqtGraph ban line leave image limits