Can't move toolbar from top/bottom to left/right and vice versa

312 Views Asked by At

Just learning how to deal with QToolBar and figured out that can't change orientation by drag&dropping it.

    mainToolBar = QToolBar(self)
    mainToolBar.setContextMenuPolicy(Qt.PreventContextMenu)
    mainToolBar.setFloatable(False)

As you can see, dropable field does not appear.

2

There are 2 best solutions below

0
JuicyKitty On

The problem was in fact that window at start tries to shrink to minimum possible size and it does not reserve space for QToolBar. I have placed QToolBar to Qt.TopToolBarArea from start and reserved width:

    def showEvent(self, event):
        self.setMinimumSize(self.width() +
            self.mainToolBar.size().height(), self.height())
0
AudioBubble On

Have you tried setting the QToolBar to not movable?

mainToolbar.setMovable(False)