Active Topics

 


Reply
Thread Tools
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.
 
Posts: 37 | Thanked: 19 times | Joined on Mar 2009 @ Scotland
#2
As an update, I think I realise what's happening and it is a Platform Dependent issue. It appears Qt by default creates or moves the Quit/Exit menu as the last top level menu item.

I've been trying to find out how to override (or just detect) this behaviour and have an app that runs equally on PC and tablet. The variable Q_WS_HILDON is supposed to be defined in Qt for maemo, but is not defined within PyQt.

If it was defined I would be happy with the following;

Code:
        try:
            Q_WS_HILDON
            menuBar.AddAction(updateAction)
            menuBar.addAction(optionsAction)
            menuBar.addAction(aboutAction)
            menuBar.addSeparator()
            menuBar.addAction(quitAction)
        except:
            fileMenu = menuBar.addMenu('&File')
            fileMenu.addAction(updateAction)
            fileMenu.addAction(optionsAction)
            fileMenu.addSeparator()
            fileMenu.addAction(quitAction)
            helpItem = menuBar.addMenu('&Help')
            helpItem.addAction(aboutAction)
But for now still stuck with this problem

Last edited by fifth; 2009-03-31 at 23:14.
 
Posts: 37 | Thanked: 19 times | Joined on Mar 2009 @ Scotland
#3
*bump*

anyone know of a way to detect hildon from python or pyqt?
 
Posts: 432 | Thanked: 645 times | Joined on Mar 2009
#4
something like this could work:

Code:
try:
    import hildon
except ImportError:
    do something
 

The Following User Says Thank You to danielwilms For This Useful Post:
Posts: 37 | Thanked: 19 times | Joined on Mar 2009 @ Scotland
#5
Originally Posted by danielwilms View Post
something like this could work:

Code:
try:
    import hildon
except ImportError:
    do something
Thanks, this does work but will have to check what kind of overheads it adds to the app since i dont use any hildon methods at the moment.
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#6
You could check for /proc/component_version but then you'd be limiting yourself to tablets, not just things which use hildon (i.e. Mer on an x86 computer)
 

The Following 2 Users Say Thank You to qwerty12 For This Useful Post:
Posts: 432 | Thanked: 645 times | Joined on Mar 2009
#7
the overhead is indeed pretty high if u don't use the hildon bindings at all afterwards. but at least I could find out that pyqt4 for maemo definitely does not support the Q_WS_HILDON option, as described in the qt4hildon wiki. but it has been reported as an enhancement there, so perhaps it will be implemented soon the hint from the developers there was as well to use the /proc directory.

Hope I could help, cheers

daniel
 
Posts: 37 | Thanked: 19 times | Joined on Mar 2009 @ Scotland
#8
Thanks qwerty12 and danielwilms.

I'm going to go with /proc/component_version suggestion. Although tablets themselves will be the target, I think it still fits my needs.

I assume qt is putting the close/quit option as last top level item for useability with stylus/finger input on the tablet. So I'm happy to follow this convention.

Thanks again.
 
Reply


 
Forum Jump


All times are GMT. The time now is 01:42.