PDA

View Full Version : Vertical QToolBar



conti
16th January 2012, 17:05
Hi everyone!
I hope i can get some help here. I'm trying to align the QActions in vertical QToolbar to the left, but i don't know how to achieve this.
I got a QToolbar with ->setOrientation( Qt::Vertical ) and setToolButtonStyle(Qt::ToolButtonTextBesideIcon)
I am adding QActions with addAction(). All QActions are aligned centered, how can i have them all aligned to the left?
Thanks for any help.

pkj
16th January 2012, 18:48
If you are using designer, simply drag the toolbar. QToolBar::setOrientation should not be used when the toolbar is used with mainwindow. Use QMainWindow::addToolBar and QMainWindow::insertToolBar to move it around.

conti
17th January 2012, 10:28
Hi thanks for your answer but it seems my questions was not precise enough.
I'm not having a problem making a QToolBar vertical. This works perfectly. I'm adding a QToolBar to a QDockWidget programmatically which is on the left side of the aplication window.
The problems begin when i start to add QActions to this QToolBar:
The QActions are all centered horizontally, but i want them to be aligned to the left inside the QToolbar.

Rikki Tikki
27th November 2013, 14:18
I am having the same issue. When moving a QToolBar to a vertical position the QActions within the toolbar are "center" aligned. I have attached an image showing what is happening. Anyone have a clue as to how these actions can be left or right aligned? This is part of a form created within QT Designer.

thanks,
9826

camoroso
4th October 2016, 10:18
has someone solved this issue?

Plankgas
28th January 2018, 12:54
In designer you have to drag the toolbar towards the middle left side of the window. When the area lights up blue you can let go.

d_stranz
28th January 2018, 17:14
In designer you have to drag the toolbar towards the middle left side of the window. When the area lights up blue you can let go

Your answer has nothing to do with the problem. The problem is not "How do I add a vertical toolbar when using Qt Designer?", it is "When I add a vertical toolbar, how do I get the icons and text to be left justified instead of centered?"

As for the original question, I think one solution would be to derive a custom QToolButton and override the QToolButton::paintEvent() to draw the icon and text with the desired alignment. In this case, you would use QToolBar::addWidget() to insert the buttons and not one of the QToolbar::addAction() methods (since these will insert a standard QToolButton and not your custom one).