I'm trying to create a desktop app with modern looking user-interface, by that I mean specifically replacing traditional menubar and toolbar with ribbon menu, e.g like one from MS Office suite.
I have achieved some progress working with QToolBar (with QActions) stacked into QTabWidget, but the problem was, it showed correctly only when I set it as CentralWidget. Later, when I wanted to implement table (QTableWidget), it failed showing anything but the table...
Method for ribbon:
def tab_menu(self):
self.tabWidget = QTabWidget()
self.tabWidget.setFixedHeight(120)
self.setCentralWidget(self.tabWidget)
self.tab1 = QFrame()
layout = QGridLayout()
addFile = QAction('Add entry', self)
addFile.setIcon(icon1)
removeFile = QAction('Remove entry', self)
removeFile.setIcon(icon2)
addFolder = QAction('New category', self)
addFolder.setIcon(icon3)
removeFolder = QAction('Remove category', self)
removeFolder.setIcon(icon4)
editFile = QAction('Change entry', self)
editFile.setIcon(icon5)
toolBar = QToolBar()
toolBar.addAction(addFile)
toolBar.addAction(removeFile)
toolBar.addAction(editFile)
toolBar.addSeparator()
toolBar.addAction(addFolder)
toolBar.addAction(removeFolder)
icon_width = 60
toolBar.setIconSize(QSize(icon_width, icon_width))
layout.setAlignment(Qt.AlignLeft)
layout.addWidget(toolBar, 0, 0)
self.tab1.setLayout(layout)
self.tabWidget.addTab(self.tab1, 'Edit')
self.tabWidget.show()
I would like to know how is it possible to "anchor" the QTabWidget to place, where should be toolbar/menubar. I saw the layout shown at https://doc.qt.io/qt-5/qmainwindow.html, but I'm not certain how to use it.