Reputation: 6158
I am trying to add a menu bar at the very top of the application, not "inside" of it where it usually wants to add it.
Quick example:
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QLabel, QMainWindow, QMenu
class Window(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("< Menu Go Here")
self.resize(400, 200)
self.centralWidget = QLabel("Hello, World")
self.centralWidget.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
self.setCentralWidget(self.centralWidget)
self._createMenuBar()
def _createMenuBar(self):
menuBar = self.menuBar()
menuBar.addMenu(QMenu("&File", self))
menuBar.addMenu("&Edit")
menuBar.addMenu("&Help")
if __name__ == "__main__":
app = QApplication(sys.argv)
win = Window()
win.show()
sys.exit(app.exec_())
Would create something like:
However I want the menu to be part of the grey line above it (same line as the icon and window title).
Upvotes: 0
Views: 20