Einzelne Buttons in ToolBar positionieren (Left/Right)
Verfasst: Samstag 19. Januar 2019, 11:19
Hallo zusammen,
möchte bei meiner ToolBar, die ich unten horizontal erstellt habe, einen Teil der Buttons links und den anderen Teil rechts positionieren.
Ist das möglich und wenn ja, wie funktioniert das?
Poste hier mal den betreffenden Code dazu:
Sollte der Code verbesserungswürdig sein, freue ich mich auch über Euren Input!
Grüße Nobuddy
möchte bei meiner ToolBar, die ich unten horizontal erstellt habe, einen Teil der Buttons links und den anderen Teil rechts positionieren.
Ist das möglich und wenn ja, wie funktioniert das?
Poste hier mal den betreffenden Code dazu:
Code: Alles auswählen
def toolbarBottom(self):
exitAction = QtGui.QAction(
QtGui.QIcon(icon_path + 'system-log-out'), 'Close', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.triggered.connect(self.close)
maxAction = QtGui.QAction(
QtGui.QIcon(icon_path + 'view-fullscreen.png'), 'Max', self)
maxAction.setShortcut('Ctrl++')
maxAction.triggered.connect(self.maximum_size)
minAction = QtGui.QAction(
QtGui.QIcon(icon_path + 'view-fullscreen.png'), 'Min', self)
minAction.setShortcut('Ctrl+-')
minAction.triggered.connect(self.minimum_size)
editAction = QtGui.QAction(
QtGui.QIcon(icon_path + 'edit-select-all.png'), 'Edit', self)
editAction.setShortcut('Ctrl+E')
editAction.triggered.connect(self.edit)
newAction = QtGui.QAction(
QtGui.QIcon(icon_path + 'document-new.png'), 'New', self)
newAction.setShortcut('Ctrl+N')
newAction.triggered.connect(self.new)
self.Bottom = QtGui.QToolBar(self)
self.Bottom.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
self.addToolBar(self.Bottom )
self.Bottom.addAction(exitAction)
self.Bottom.addAction(maxAction)
self.Bottom.addAction(minAction)
self.Bottom.addAction(editAction)
self.Bottom.addAction(newAction)
self.Bottom.setAllowedAreas(
QtCore.Qt.TopToolBarArea
| QtCore.Qt.BottomToolBarArea
| QtCore.Qt.LeftToolBarArea
| QtCore.Qt.RightToolBarArea
)
self.addToolBar(QtCore.Qt.BottomToolBarArea, self.Bottom)
self.Bottom.topLevelChanged.connect(self.handle_floating)
Grüße Nobuddy