#include// create label widget and set its text content QLabel *label = new QLabel("Hello World!"); // set consistent margins around the label's contents label->setContentsMargins(10, 10, 10, 10);
#includePackage Library: Qt Library.#include // create a pixmap containing an image QPixmap pixmap(":/images/example.png"); // create label widget and set its pixmap content QLabel *imageLabel = new QLabel; imageLabel->setPixmap(pixmap); // set larger bottom margin around the pixmap content imageLabel->setContentsMargins(0, 0, 0, 20);