[PyQt] QShortcut causes seg fault with non-widget context
Robert Kent
rob at gulon.co.uk
Thu Oct 30 13:42:55 GMT 2014
Hi All,
I'm trying to use QShortcut to set a global shortcut for my application,
however if I set the context to anything other than Qt.WidgetContext (I.e.
Qt.ApplicationContext in my case) the application crashes. This behaviour is
true for Mac OSX 10.8 and Windows 7. I'm using Python 2.7.2, Qt4.8 and
PyQt4.10. The following little program is a demo and crashes for me:
import sip
sip.setapi('QString',2)
sip.setapi('QVariant',2)
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class Widget(QWidget):
def __init__(self, parent=None, **kwargs):
QWidget.__init__(self, parent, **kwargs)
self.shortcut=QShortcut(
"Ctrl+P",
self,
context=Qt.ApplicationShortcut,
activated=self._sca
)
@pyqtSlot()
def _sca(self): print "SCA"
if __name__=="__main__":
from sys import argv, exit
a=QApplication(argv)
w=Widget()
w.show()
w.raise_()
exit(a.exec_())
Just wondering if anybody has had this issue and can tell me what I'm doing
wrong or if this is a genuine bug.
Thanks very much, Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141030/1bcfc478/attachment.html>
More information about the PyQt
mailing list