3

I want let the two code work simultaneously,but I don't know how to do that.

self.botV.setAlignment(Qt.Aligntop)
self.botV.setAlignment(Qt.AlignCenter)

It just do the last one.

kevin880701
  • 85
  • 1
  • 2
  • 10

1 Answers1

4

I suppose you want a central horizontal alignment and the vertical alignment in the top, then you must use the operator |, also be careful with the case of the variables, Qt uses camelcase:

self.botV.setAlignment(Qt.AlignHCenter | Qt.AlignTop)
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • THANKS!! I succeeded – kevin880701 Jun 07 '19 at 14:54
  • 3
    The reason this works, is that generally Qt uses binary flags that can be "or'd" together in order to combine them. If `Aligntop == 1` and `AlignCenter == 2` then setting one then the other will just overwrite the previous. If you instead combine them first, you get both: `Aligntop | AlignCenter ≡ 01 | 10 == 11` (in binary) – Aaron Jun 07 '19 at 15:02
  • OK,I understand – kevin880701 Jun 08 '19 at 02:31