Howto: align text within a label

Post Reply
User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Howto: align text within a label

Post by Vadi »

By default, text in labels is centered vertically. Turns out you can fix that!

If you look at http://qt-project.org/doc/qt-4.8/qlabel.html, you'll notice near the top that the label has 'Properties'. You can adjust those properties via stylesheets by prefixing qproperty- at the start - so qproperty-alignment will allow you to adjust the alignment of text in a label.

For a list of possible alignment values, see the documentation here.

To set one value, you would use the following in your stylesheet:
Code: [show] | [select all] lua
qproperty-alignment: 'AlignTop';
To set multiple values, separate them with a pipe | sign:
Code: [show] | [select all] lua
qproperty-alignment: 'AlignTop | AlignHCenter';
See Geyser page for practical examples using Geyser.

Post Reply