steffen
steffen

Reputation: 8958

How to add a stretchable spacer in a QToolbar?

I want some of my toolbar actions to appear left-bound and some right-bound. In GTK, I remember adding a stretchable (expandable) separator. How do I achieve that in Qt?

Upvotes: 24

Views: 19617

Answers (1)

Synxis
Synxis

Reputation: 9388

You can use an empty widget with automatic expanding, it works like the spacers you can use in Qt Designer:

tb = my_toolbar;

QWidget* empty = new QWidget();
empty->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
tb->addWidget(empty);

tb->addWidget(otherWidget);

Upvotes: 49

Related Questions