custom toolbar layout
Solved
General and Desktop
-
i need to have a layout like this:
action, action (a lot space) action
so i thought to create a toolbar, and add actions to it.
i also created a layout where i added
widgetForAction
s for all the 3 actions:layout->addWidget(toolbar->widgetForAction(action)); layout->addStretch(); layout->addWidget(toolbar->widgetForAction(action));
but well i can't set the layout on the toolbar since it already has one.
is there a solution to this? -
Hi
You can try using a QSpacerItem.
http://doc.qt.io/qt-5/qspaceritem.html -
That looks a bit odd syntax. )
Anyway i checked the docs. not sure it takes one. sorry. my bad.Anyway, you can do like this
... insert left actions first .. QWidget* empty = new QWidget(); empty->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); ui->mainToolBar->addWidget(empty); // this will be right aligned QAction *test= new QAction(this); test->setText("RIGHT"); ui->mainToolBar->addAction(test);
-
@user4592357
me too. i thought Spacers could be put in any layout :)