For example suppose the following tool bar:
const auto toolbar = new QToolBar();
const auto btn1 = new QToolButton("short label");
btn1->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
toolbar->addWidget(btn1);
const auto btn2 = new QToolButton("***** large label *****");
btn2->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
toolbar->addWidget(btn2);
How to make a QToolBar
or a QHBoxLayout
to layout items with exact same width? in this example both buttons should be of same width and get as minimum space as possible. i.e. not using QSizePolicy::Expanding
. Please note that setting hard coded sizes is not an option for me since in my app, user can dynamically change font size.