[Qt-interest] keyboard events

Sean Harmer sean.harmer at maps-technology.com
Mon Apr 27 12:11:20 CEST 2009


On Monday 27 April 2009 11:04:17 Giancarlo Amati wrote:
> Hello,
> sorry to bother everybody with this "silly" question but I can't find
> anything adressing me to the keyboards event management: I have a
> CMainWindow derived from QMainWindow class. now, I want connect my class to
> the keyboard events. So I'll call:
>
>         QObject::connect(this,SIGNAL(keyPressEvent(QKeyEvent
> *)),this,SLOT(getKeyboardPressed(QKeyEvent *)) );
>
> where this is the pointer to an object beloging to CMainWindow class. Now,
> what happens is that I received a warning message saying that there is now
> keyPressEvent method decleared...how? I've checked the QWidget class and
> actually there is one :(
Yes there is a keyPressEvent() method but it is *not* a signal. Instead simply 
override this virtual function and do your handling in there. You may wish to 
re-read the signals/slots docs.

Cheers,

Sean




More information about the Qt-interest-old mailing list