<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>Hey,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>Sorry forgot to mention to ambiguous shortcuts. :)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>Also note that actions added to the widgets will also show up in the widgets context menu.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'><a href="http://doc.qt.io/qt-4.8/qwidget.html#addAction">http://doc.qt.io/qt-4.8/qwidget.html#addAction</a><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>In general, I prefer using action where ever it is possible. They are very well support all around and give me a nice separation from the visuals.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'><o:p> </o:p></span></p><div><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>Tibold Kandrai<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>Software Architect & Engineer<o:p></o:p></span></p></div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'> Frank Rueter | OHUfx [mailto:frank@ohufx.com] <br><b>Sent:</b> Tuesday, 12 July, 2016 01:09<br><b>To:</b> Tibold Kandrai <kandraitibold@gmail.com><br><b>Cc:</b> pyside@qt-project.org<br><b>Subject:</b> Re: [PySide] QShortcut suppressed by parent widget?<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Ah, much nicer, thanks.<br>Though I am getting this at the moment:<br>    QAction::eventFilter: Ambiguous shortcut overload: I<br><br>Will investigate further.<br>Thanks Tibold.<br><br>frank<br><br><o:p></o:p></p><div><p class=MsoNormal>On 07/11/2016 07:42 PM, Tibold Kandrai wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>Hey,</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'> </span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>You could use actions:</span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'><a href="https://gist.github.com/tibold/7451adb89c41c3718148168cee191ac3">https://gist.github.com/tibold/7451adb89c41c3718148168cee191ac3</a></span><o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'> </span><o:p></o:p></p><div><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>Tibold Kandrai</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>Software Architect & Engineer</span><o:p></o:p></p></div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'> </span><o:p></o:p></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext'> PySide [<a href="mailto:pyside-bounces+kandraitibold=gmail.com@qt-project.org">mailto:pyside-bounces+kandraitibold=gmail.com@qt-project.org</a>] <b>On Behalf Of </b>Frank Rueter | OHUfx<br><b>Sent:</b> Monday, 11 July, 2016 09:17<br><b>To:</b> Alexey Vihorev <a href="mailto:vihorev@gmail.com"><vihorev@gmail.com></a><br><b>Cc:</b> <a href="mailto:pyside@qt-project.org">pyside@qt-project.org</a><br><b>Subject:</b> Re: [PySide] QShortcut suppressed by parent widget?</span><o:p></o:p></p></div></div><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Thanks, but it doesn't seem to make a difference.<o:p></o:p></p><div><p class=MsoNormal>On 07/11/2016 07:13 PM, Alexey Vihorev wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><div><div><p class=MsoNormal style='margin-bottom:12.0pt'>self.shortcut = QtGui.QShortcut(self, context=QtCore.Qt.WidgetShortcut)<o:p></o:p></p></div><p class=MsoNormal>The context. In your case IMO it should be <code><span style='font-size:10.0pt'>QtCore.Qt.WindowShortcut. </span></code>More <a href="http://doc.qt.io/qt-4.8/qt.html#ShortcutContext-enum">here</a><o:p></o:p></p></div></div><div><p class=MsoNormal> <o:p></o:p></p><div><p class=MsoNormal>2016-07-11 9:30 GMT+03:00 Frank Rueter | OHUfx <<a href="mailto:frank@ohufx.com" target="_blank">frank@ohufx.com</a>>:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'><div><p class=MsoNormal style='margin-bottom:12.0pt'>Hi all,<br><br>below is some test code that shows the problem I'm having, where a shortcut assigned to a child widget will not be triggered once it's part of the main widget.<br>It works if the widget is called by itself but not when it's part of a parent widget.<br><br>I have been searching the internet for an solution but haven't had any luck.<br><br>Does anybody know what I'm doing wrong?<br><br>Cheers,<br>frank<br><br>import sys<br>from PySide import QtGui, QtCore<br><br><br>class MainWidget(QtGui.QWidget):<br>    <br>    def __init__(self, parent=None):<br>        super(MainWidget, self).__init__(parent)<br>        self.makeUI()<br>       <br>    def makeUI(self):<br>        self.layout = QtGui.QHBoxLayout()<br>        self.setLayout(self.layout)<br>        sw1 = SubWidget('test1')<br>        sw2 = SubWidget('test2')<br>        sw3 = SubWidget('test3')<br>        self.layout.addWidget(sw1)<br>        self.layout.addWidget(sw2)<br>        self.layout.addWidget(sw3)<br><br>class SubWidget(QtGui.QLabel):<br>    def __init__(self, text, parent=None):<br>        super(SubWidget, self).__init__(parent)<br>        self.setText(text)  <br>        self.shortcut = QtGui.QShortcut(self, context=QtCore.Qt.WidgetShortcut)<br>        self.shortcut.setKey('i')<br>        self.shortcut.activated.connect(self.showInfoWidget)<br><br>    def showInfoWidget(self, text):<br>        print 'showing info for', self.text()<br><br><br>if __name__ == '__main__':<br>    app = QtGui.QApplication([])<br>    w = MainWidget()<br>    w.show()<br>    sys.exit(app.exec_())<span style='color:#888888'><br><br><br><br></span><o:p></o:p></p><div><p class=MsoNormal><span style='color:#888888'>-- </span><o:p></o:p></p><table class=MsoNormalTable border=0 cellpadding=0 width=524 style='width:393.0pt'><tr><td style='padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal align=center style='text-align:center'><a href="http://www.ohufx.com" target="_blank"><span style='text-decoration:none'><img border=0 width=50 height=50 style='width:.5208in;height:.5208in' id="_x0000_i1025" src="cid:image001.png@01D1DC22.B7126590" alt="ohufxLogo 50x50"></span></a><o:p></o:p></p></td><td style='padding:.75pt .75pt .75pt .75pt'><p class=MsoNormal align=center style='text-align:center'><strong><span style='font-size:10.0pt'><a href="http://ohufx.com/index.php/vfx-compositing" target="_blank">vfx compositing</a></span> | </strong><strong><span style='font-size:10.0pt'><a href="http://ohufx.com/index.php/vfx-customising" target="_blank">workflow customisation and consulting</a> </span></strong><o:p></o:p></p></td></tr></table></div></div><p class=MsoNormal style='margin-bottom:12.0pt'><br>_______________________________________________<br>PySide mailing list<br><a href="mailto:PySide@qt-project.org">PySide@qt-project.org</a><br><a href="http://lists.qt-project.org/mailman/listinfo/pyside" target="_blank">http://lists.qt-project.org/mailman/listinfo/pyside</a><o:p></o:p></p></blockquote></div><p class=MsoNormal><br><br clear=all><br>-- <o:p></o:p></p><div><p class=MsoNormal>Алексей Вихорев<o:p></o:p></p></div></div></blockquote><p class=MsoNormal> <o:p></o:p></p></blockquote><p class=MsoNormal><o:p> </o:p></p></div></body></html>