Skip to content

Instantly share code, notes, and snippets.

@nvbn
Created September 26, 2012 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvbn/3790935 to your computer and use it in GitHub Desktop.
Save nvbn/3790935 to your computer and use it in GitHub Desktop.
Bug #1057167 “global menu not work with PySide apps” : Bugs : appmenu-qt
from PySide.QtCore import Slot, QTranslator, QLocale, Signal, QSettings
from PySide.QtGui import QApplication, QSystemTrayIcon, QMenu, QIcon, QMainWindow
from PySide import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 25))
self.menubar.setObjectName("menubar")
self.menuSd = QtGui.QMenu(self.menubar)
self.menuSd.setObjectName("menuSd")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.action213 = QtGui.QAction(MainWindow)
self.action213.setObjectName("action213")
self.actionSdf = QtGui.QAction(MainWindow)
self.actionSdf.setObjectName("actionSdf")
self.menuSd.addAction(self.action213)
self.menuSd.addAction(self.actionSdf)
self.menubar.addAction(self.menuSd.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.menuSd.setTitle(QtGui.QApplication.translate("MainWindow", "sd", None, QtGui.QApplication.UnicodeUTF8))
self.action213.setText(QtGui.QApplication.translate("MainWindow", "213", None, QtGui.QApplication.UnicodeUTF8))
self.actionSdf.setText(QtGui.QApplication.translate("MainWindow", "sdf", None, QtGui.QApplication.UnicodeUTF8))
class Editor(QMainWindow):
def __init__(self, *args, **kwargs):
QMainWindow.__init__(self, *args, **kwargs)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
app = QApplication([])
e = Editor()
e.show()
app.exec_()
@borjapazr
Copy link

It works fine when:
self.menubar = QtGui.QMenuBar(MainWindow) # replace this
self.menubar = MainWindow.menuBar() # with this
self.menubar = QtGui.QMenuBar() # or this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment