How to center a QToolButton in QToolBar?
I add QToolButton into vertical QToolBar (using addWidget() method) and it is aligned to the left.
How can I aligned it to the center??
Top I have
Bottom I need
In C++, Qt 5.0.1.
Thanks for quick answer!
use a vertical box layout, add the toolbutton to the layout with Qt::AlignCenter and then set the layout to the toolbar
QVBoxLayout is not good solution, because I have a QActions in ToolBar and QAction can not insert into Layout. Some easier solution did not exist? Something like stylesheet?
What you can do is fiddle with the setContentsMargins of the toolbar and work your way untill you align the items as you want.
QAction is nothing more then a quick way to utilize the signal/slot methode. An other option is to remove the actions and in the constructor of the window set the signal / slots as needed.