QLabel *myLabel = new QLabel("Hello World"); myLabel->setFixedHeight(50);
QLabel *myLabel = new QLabel("This is a long text that needs to be wrapped"); myLabel->setWordWrap(true); myLabel->setFixedHeight(100);This code creates a QLabel widget with a long text that will be automatically wrapped to fit within the fixed height of 100 pixels. Package Library: Qt QtCore Library.