View Single Post
Posts: 37 | Thanked: 19 times | Joined on Mar 2009 @ Scotland
#1
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;

Code:
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?

Last edited by fifth; 2009-04-01 at 17:34.