text in label incorrectly displayed

40 Views Asked by At

I'm unable to correctly display a text on a QLabel, here's how it looks:

enter image description here

How do I modify it to get this result:

The result

2

There are 2 best solutions below

0
AudioBubble On BEST ANSWER

In code: after create widget you can try to relocate your text using setAligment fuction, in class QLabel. For example, locating text from top to down:

myLabel->setAlignment(Qt::AlignTop)

In Designer you can use field Aligment-Vertical.

0
A.R.M On

From 4.3 and above, any designable Q_PROPERTY can be set using the qproperty-<property name> syntax.

For your case, you could use the following stylesheet on your label:

qproperty-alignment: AlignVTop;
qproperty-alignment: AlignHCenter;
qproperty-wordWrap: true;
/*an addition in case it's useful to set text using stylesheets*/
qproperty-text: 'Mercredi 19.01.2021';

Sources: