-1

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 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.