Rotate QLabel 90° in Qt: CSS Transform Guide
In Qt, you can achieve label rotation by using the setStyleSheet method of QLabel. The specific steps are as follows:
- Create a QLabel object, for example:
QLabel *label = new QLabel("Hello, World!");
- Use the setStyleSheet method to set the rotation style of the label, for example:
label->setStyleSheet("transform: rotate(90deg);");
By setting the transform property to rotate(90deg), the label can be rotated by 90 degrees. Then simply add the label to the window where it needs to be displayed.