Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QToolBar Change Height

In my project I have a QToolBar with default size and size policy. I want to increase the height of the toolbar to 36px.

So far I have tried:

  • Setting a stylesheet property to the toolbar: height: 36px;
  • Setting the toolbar object's size policy to fixed: toolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
  • Setting the minimumHeight: toolBar->setMinimumHeight(36);
  • Setting the layout size constraint toolBar->layout()->setSizeConstraint(QLayout::SetMinimumSize)
  • All of those at once

And nothing increases the height of the toolbar. The only thing that works is increasing the size of the QToolButton objects within the bar, but this is not what I want to do. I only want the toolbar itself taller.

Any suggestions? Thanks for your time.

EDIT: My current solution was to add a margin to the QToolButton objects in the toolbar. I still don't like this because I have varying object types in the toolbar.... frustrating.

like image 593
mrg95 Avatar asked May 13 '26 05:05

mrg95


1 Answers

toolBar->setFixedHeight(36); - works well.

But if I set icon size after this:

toolBar->setFixedHeight(36); 
toolBar->setIconSize(QSize(10, 10));

height breaks down. Also it happens if I set icon size via stylesheet.

Changing of calls order helps:

toolBar->setIconSize(QSize(10, 10));
toolBar->setFixedHeight(36);
like image 159
Draks Avatar answered May 15 '26 20:05

Draks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!