Hi i put the class eventfilter but how i can show in the main of my program the events of this filter. Class:
class FiltroDeEventosPersonalizado
{
Q_OBJECT
protected:
};
class FiltroDeEventosPersonalizado
: public QObject
{
Q_OBJECT
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
};
To copy to clipboard, switch view to plain text mode
Method :
bool
FiltroDeEventosPersonalizado::eventFilter(
{
if (event
->type
() == QEvent::KeyPress) { QKeyEvent keyEvent
= static_cast<QKeyEvent>
(event
);
if( keyEvent->key() == Qt::Key_A )
qDebug() << "Tecla 'A' presionada";
return true;
}
return QObject::eventFilter(obj, event
);
}
bool
FiltroDeEventosPersonalizado::eventFilter(
QObject obj,
QEvent event)
{
if (event->type() == QEvent::KeyPress) {
QKeyEvent keyEvent = static_cast<QKeyEvent>(event);
if( keyEvent->key() == Qt::Key_A )
qDebug() << "Tecla 'A' presionada";
return true;
}
return QObject::eventFilter(obj, event);
}
To copy to clipboard, switch view to plain text mode
Main of my program:
#include <QCoreApplication>
#include <filtrodeeventospersonalizado.h>
#include <QDebug>
int main(int argc, char *argv[])
{
//i want show the events with Qdebug
return a.exec();
}
#include <QCoreApplication>
#include <filtrodeeventospersonalizado.h>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
//i want show the events with Qdebug
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks