Vertical QToolBar from MainWindow
Asked Answered
A

2

5

What I want: http://puu.sh/3oUjh.jpg What I have: http://puu.sh/3oUnI.png

The toolbar is made in mainwindow.ui, ive tried ui->_toolbar->setLayoutDirection(Qt::LeftToolBarArea);

But I get this error: no matching function for call to 'QToolBar::setLayoutDirection(Qt::ToolBarArea)'

Associate answered 26/6, 2013 at 18:32 Comment(0)
C
13

You can use QToolBar::orientation property:

ui->myToolbar->setOrientation(Qt::Vertical);

You can also use QMainWindow::addToolBar:

addToolBar(Qt::LeftToolBarArea, ui->myToolbar);

Note that by default the user is able to drag toolbars and attach them to any side of the main window.

Commodity answered 26/6, 2013 at 18:37 Comment(3)
@Cpp and Qt Beginner: Pssst, you should mark the replies as answers if it helped youResidential
haven't had a chance to try it yet. was not my upvote =/. I'll be sure to mark as answered if it works.Associate
addToolBar(Qt::LeftToolBarArea, ui->myToolbar); worked wondersAssociate
R
0

You're using the wrong enum for setLayoutDirection:

// Don't use this.  You need to use a different method 
// if you want it placed against the left side.
enum ToolBarArea {
    LeftToolBarArea = 0x1,
    RightToolBarArea = 0x2,
    TopToolBarArea = 0x4,
    BottomToolBarArea = 0x8,

    ToolBarArea_Mask = 0xf,
    AllToolBarAreas = ToolBarArea_Mask,
    NoToolBarArea = 0
};

You need to use something from Qt::LayoutDirection:

enum LayoutDirection {
    LeftToRight,
    RightToLeft,
    LayoutDirectionAuto
};

ui->_toolbar->setLayoutDirection(Qt::LeftToRight);
Residential answered 26/6, 2013 at 18:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.