fifth
03-31-2009, 05:08 PM
I've got an annoying problem with my PyQt application menu when running on Maemo (works as expected in KDE).
Essentially the 'Quit' item is not added to the File menu, but instead is added as last top level item on the menu bar. The code which shows the problem is;
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow,self).__init__(parent)
quitAction = QAction('&Quit', self)
quitAction.setShortcut('Ctrl+Q')
quitAction.setStatusTip('Exit application')
self.connect(quitAction, SIGNAL('triggered()'), SLOT('close()'))
aboutAction = QAction('&About', self)
aboutAction.setStatusTip('About App ...')
self.connect(aboutAction, SIGNAL("triggered()"), self.showAbout)
menuBar = self.menuBar()
menuBar.clear()
fileMenu = menuBar.addMenu('&File')
fileMenu.addAction(quitAction)
helpItem = menuBar.addMenu('&Help')
helpItem.addAction(aboutAction)
def showAbout(self):
pass
app = QApplication(sys.argv)
form = MainWindow()
form.show()
app.exec_()
I guess this is a platform dependent issue and I have tried using MenuRoles on the actions. Anyone know what's wrong with my code?
Essentially the 'Quit' item is not added to the File menu, but instead is added as last top level item on the menu bar. The code which shows the problem is;
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow,self).__init__(parent)
quitAction = QAction('&Quit', self)
quitAction.setShortcut('Ctrl+Q')
quitAction.setStatusTip('Exit application')
self.connect(quitAction, SIGNAL('triggered()'), SLOT('close()'))
aboutAction = QAction('&About', self)
aboutAction.setStatusTip('About App ...')
self.connect(aboutAction, SIGNAL("triggered()"), self.showAbout)
menuBar = self.menuBar()
menuBar.clear()
fileMenu = menuBar.addMenu('&File')
fileMenu.addAction(quitAction)
helpItem = menuBar.addMenu('&Help')
helpItem.addAction(aboutAction)
def showAbout(self):
pass
app = QApplication(sys.argv)
form = MainWindow()
form.show()
app.exec_()
I guess this is a platform dependent issue and I have tried using MenuRoles on the actions. Anyone know what's wrong with my code?