[solved]How to center toolbuttons in horizontal toolbar?
-
You should set the policy on the widgets, not the toolbar
-
[quote author="SGaist" date="1400570992"]You should set the policy on the widgets, not the toolbar[/quote]
i tried this but it didnt work..am i still doing something wrong?@void BitcoinGUI::createToolBars()
{
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
QWidget *spacerWidget = new QWidget(this);
spacerWidget>setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
spacerWidget->setVisible(true);
toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
toolbar->addWidget(spacerWidget);
toolbar->addAction(overviewAction);
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
toolbar->addAction(addressBookAction);
toolbar->addWidget(spacerWidget);
@ -
You need two spacer widgets, otherwise you are just moving it from left to right
-
No you can't, addWidget doesn't mean "copy that widget in the toolbar" (you can't copy widgets by the way nor any QObject derived class)
So yes you have to create another spacer widget
-
You're welcome !
Did you got it working ?
-
Nice ! Then please update the thread title prepending [solved] so other forum users may know a solution has been found :)