Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add stretchable spacer in Qtoolbar?

Tags:

c++

qt

qt-creator

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

I use Qt Creator but I am not afraid of editing source, so either solution is greatly appreciated.

like image 595
steffen Avatar asked Oct 04 '12 15:10

steffen


1 Answers

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);
like image 97
Synxis Avatar answered Oct 21 '22 05:10

Synxis