Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt: Align Text Center and Left using StyleSheet

Tags:

c++

qt

I want to align the text in a QLabel in such a way that horizontal alignment is left and vertical alignment is center with word-wrap. Currently I am doing something like this

QLabel
{
    qproperty-alignment: AlignLeft;
}

I want to know how I can set text vertical and horizontal alignment individually.

like image 641
MistyD Avatar asked Feb 09 '14 22:02

MistyD


People also ask

How do you align text to the center in CSS?

To center text in CSS, use the text-align property and define it with the value 'center. ' You can use this technique inside block elements, such as divs. You can also center text in HTML, which is useful if you only want to center individual elements on the page on a case-by-case basis.

How do you center text in Qlabel?

You can adjust the placement of labels with the setAlignment() method. If you set it with Qt. AlignCenter, it will be aligned in the center both horizontally and vertically.


1 Answers

Most likely you should write something like:

 qproperty-alignment: 'AlignVCenter | AlignLeft';
 qproperty-wordWrap: true;
like image 103
Predelnik Avatar answered Nov 06 '22 15:11

Predelnik