Does your code look like this?:
{
qDebug("EventFilter type: %d", event->type());
if(event
->type
() == QEvent::KeyPress ) {
QKeyEvent *ke
= static_cast<QKeyEvent
*>
(event
);
int keyValue = ke->key();
switch ( keyValue )
{
case Qt::Key_0: case Qt::Key_1: case Qt::Key_2: case Qt::Key_3 : case Qt::Key_4: case Qt::Key_5: case Qt::Key_6: case Qt::Key_7: case Qt::Key_8: case Qt::Key_9 :
ListBoxA->numClicked((char *)ke->text().latin1());
break;
}
return true;
}
return QObject::eventFilter(obj,event
);
}
bool MyClass::eventFilter( QObject* obj, QEvent *event )
{
qDebug("EventFilter type: %d", event->type());
if(event->type() == QEvent::KeyPress )
{
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
int keyValue = ke->key();
switch ( keyValue )
{
case Qt::Key_0: case Qt::Key_1: case Qt::Key_2: case Qt::Key_3 : case Qt::Key_4: case Qt::Key_5: case Qt::Key_6: case Qt::Key_7: case Qt::Key_8: case Qt::Key_9 :
ListBoxA->numClicked((char *)ke->text().latin1());
break;
}
return true;
}
return QObject::eventFilter(obj,event);
}
To copy to clipboard, switch view to plain text mode
Please notice that in following line, QObject can be something else, for example QWidget if that is the base class of MyClass:
return QObject::eventFilter(obj,event
);
return QObject::eventFilter(obj,event);
To copy to clipboard, switch view to plain text mode
Bookmarks