[PyQt] About keyPressEvent

"Gustavo A. Dí­az" gustavo.diaz at gmail.com
Thu Aug 23 04:54:59 BST 2007


I did this time:

def keyPressEvent(self, event):
             if event.key() == QtCore.Qt.Key_Escape:
                 self.hide()
           
        if event.key() == QtCore.Qt.Key_Alt + QtCore.Qt.Key_Escape:
            self.hide()

Esc key only, hides the app.
Alt + Esc does not, it just close the app.

What is wrong?

Thanks.


Cheers.
-- 
/Gustavo A. Díaz/
*GDNet Projects*
www.gdnet.com.ar <http://www.gdnet.com.ar>
Gustavo A. Díaz

Sundance escribió:
> Gustavo A. Dí­az wrote:
>
>   
>> As i said, only Escape key.
>>
>> I want to know to do the same but with alt + Escape....... or which
>> is the way to do it...
>>     
>
> Hi Gustavo,
>
> I am not sure I understand what it is that gives you trouble here. Is it 
> that you don't know how to go about it, or is it that it doesn't work 
> properly for you?
>
> In case it's the former, you will probably want to wrap the window 
> hiding code under a QAction, and give that QAction the 
> shortcut 'Alt+Esc' with QAction.setShortcut().
>
> Remember that a QAction must be added to a widget (with 
> QWidget.addAction()) before its shortcut will work.
>
> With kind regards,
>
> -- S.
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>   



-------------- next part --------------
Skipped content of type multipart/related


More information about the PyQt mailing list