Aligning text on QLabel with Style Sheets in PyQt6

RedHuli redhuli.comments at
Fri Oct 1 16:32:38 BST 2021


I have a quick question. Back in PyQt5, I could use stylesheets and QObject
properties for aligning text, like so:
label = QLabel("Test")
label.setStyleSheet("qproperty-alignment: AlignCenter")

I know I can use label.setAlignment(Qt.AlignmentFlag.AlignCenter) in PyQt6.

What I was more so curious about is if Q_PROPERTY is still available in
PyQt6. I haven't seen anything about it being removed. I assume that I can
still use it and that something is wrong with my syntax.

Thanks for your help!

Joshua Willman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the PyQt mailing list