change the size of a widget
Solved
General and Desktop
-
greetings to everyone,
I have a problem that I can't solve, here's the problem: I have a widget(container) that contains a label to display the text but I want to make the size of the widget(container) vary according to the number of characters in the label -
-
This post is deleted!
-
@mrjj still nothing the size does not vary horizontally
Here's my code maybe I misspelled it:QVBoxLayout *layout = new QVBoxLayout; layout->setSizeConstraint(QLayout::SetMinimumSize); this->setLayout(layout); for(int i = 0; i < 5; i++) { QLabel *label = new QLabel; label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); label->setWordWrap(true); label->setText("This is a very long text. "); layout->addWidget(label); }
I even reduced the number of characters to see if it works.