[SOLVED] Centering QToolButton in Vertical QToolBar
-
Hello,
I created a vertical QToolBar outside of QDesigner and added various QToolButton widgets to the toolbar. I am finding it hard to horizontally align the buttons within the vertical toolbar. Right now they are all oriented on the left and it does not look to pleasing. I was thinking about using QVBoxLayout, but got stuck on how to put the layout into the toolbar, especially with separators. If anyone has a similar or completely different approach for centering the buttons please advise.
Thanks!
-
you can also create the QToolButtons by yourself, place them with a layout in a plane QWidget and "add this QWidget to the tool bar":http://qt-project.org/doc/qt-4.8/qtoolbar.html#addWidget.
-
[quote author="raven-worx" date="1371710345"]you can also create the QToolButtons by yourself, place them with a layout in a plane QWidget and "add this QWidget to the tool bar":http://qt-project.org/doc/qt-4.8/qtoolbar.html#addWidget. [/quote]
I do not want to do this because , and correct me if I am wrong, there is no way to make a vertical toolbar on the left of the screen is you use Designer. I had to manually make it with code so I need a manual way of centering the icons in my vertical toolbar.
-
yes and why is my advise not possible with "the coding way"?
-
[quote author="raven-worx" date="1371726960"]yes and why is my advise not possible with "the coding way"?[/quote]
Oh haha, apologies. I read your post wrong. That is what I believe I am trying to do however when I try to add my layout to the toolbar it says I can't add a layout to it, it must be a widget. I can do what you said and put them in a plane widget, but then how do I add a separator between them in the layout?
Update: I got it to work, thanks a bunch. I just missed that middle step of throwing the layout in a widget. But I am still not sure how to add separators in between the buttons using this method...
-
instead of adding all tool buttons to the widget you should create for each tool button a wrapper-widget and add this to the toolbar.