Answer the question
In order to leave comments, you need to log in
Qt. How to push the contents of a QVBoxLayout to the top?
I have QRadioButtons inside QVBoxLayout, and it is not known in advance how many there will be, because it depends on how the file is parsed. I wanted to add a QSpacerItem to the layout, but there you need to specify the height and width in the constructor, setFixedHeight for QRadioButtons also does not work, they still stretch in height to the entire widget. How to be?
Answer the question
In order to leave comments, you need to log in
0. Read any Qt tutorial, experiment with QtDesigner. Save a lot of time on such elementary questions.
1. Without code, it is impossible to say where the error is, why your buttons with such a modifier are stretched.
2. Read the documentation, in this case how to use QSpacerItem, and what are the values in the constructor. Or Google ask before asking a question.
3. https://doc.qt.io/archives/qt-4.8/qboxlayout.html#...
The easiest way to place one grid inside another and add a spacer
auto layout = new QVBoxLayout(parentWidget);
auto radioLayout = new QVBoxLayout();
radioLayout->addWidget(radio1 = new QRadioButton());
...
layout->addLayout(radioLayout);
layout->addStretch();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question