PDA

View Full Version : KeyPressEvent Playing up



Atomic_Sheep
29th August 2013, 11:29
Hi Guys,

Trying to get my keypressevent working, but it's being stubborn:


void GLWidget::keyPressEvent(QKeyEvent *cKeyEventPtr)
{
qDebug() << m_bShow;
qDebug() << cKeyEventPtr;
if(cKeyEventPtr->key() == Qt::Key_F1 && m_bShow == ON)
{
qDebug() << m_bShow;
this->hide();
}
else if(cKeyEventPtr->key() == Qt::Key_F1 && m_bShow == OFF)
{
qDebug() << m_bShow;
this->show();
}
}

It's not showing any lines of code when I start bashing all my keys on my keyboard, so not sure why this is the case. My mouse click events are working fine :confused:.

I've got:

#include <QKeyEvent>

wagmare
29th August 2013, 11:38
did u checked focus policy
http://doc.qt.digia.com/4.7/qwidget.html#focusPolicy-prop