#include int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); QWidget wdg; QGridLayout *l = new QGridLayout(&wdg); l->addWidget(new QLabel("Here we have quite a long text in a layout!"), 0 , 0, 1, 1); l->addWidget(new QLabel("This text is even longer coz width matters in this issue"), 1 , 1, 1, 1); l->setSizeConstraint(QLayout::SetFixedSize); wdg.show(); app.exec(); }