QLabel* myLabel = new QLabel("Hello World"); myLabel->setMaximumSize(QSize(200, 100));
QLabel* myLabel = new QLabel("Image"); QPixmap pixmap("myImage.png"); myLabel->setPixmap(pixmap); myLabel->setMaximumSize(pixmap.size().width(), pixmap.size().height());This code creates a `QLabel` widget with an image set as its content. The maximum size of the label is set to be the size of the image, so it cannot be resized larger than the image dimensions. The `setMaximumSize` function is part of the Qt Core module, included in the Qt library.