E
E
Egorithm2020-06-03 17:34:47
Qt
Egorithm, 2020-06-03 17:34:47

Qt. How to set a fixed height layout in QGridLayout?

I am creating a 2 by 2 grid from a QGridLayout. I put QToolBar in the first line, QSplitter in the second (two more widgets there so that there is a slider between them).

main_layout = new QGridLayout{this};
toolbar = new QToolBar{this};
splitter = new QSplitter{this};

// toolbar->setFixedHeight(50);
toolbar->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Minimum);
toolbar->addAction("test");

main_layout->addWidget(toolbar,0,0,2,1);
main_layout->addWidget(splitter,1,0,2,1);

But this doesn't work (neither setFixedHeight nor setSizePolicy). QToolBar takes up too much space in height.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ighor July, 2020-06-03
@EgoRusMarch

It is necessary to apply setFixedHeight to the toolbar itself

A
Alexander Ananiev, 2020-06-03
@SaNNy32

Have you tried adding a VerticalSpacer?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question