Hi guys, unfortunately, I still have problems, even with the event filter.
It seems to not work fine for me, because even when the eventFilter method return true the event is forwarded to the QTableWidget derived object.
This is my code of the event filter object:
#include <QKeyEvent>
#include "TextProcessor.h"
{
if (evt
->type
() == QEvent::KeyPress) {
QKeyEvent *keyEvent
= static_cast<QKeyEvent
*>
(evt
);
if (keyEvent->key() == Qt::Key_Return)
{
if (keyEvent->modifiers() == Qt::ControlModifier)
{
qWarning("Ctrl");
emit escapeCharPressed();
return false;
}
else
{
qWarning("Enter");
// emit lineFeed();
return true;
}
}
else
{
return false;
}
}
else
{
return QObject::eventFilter(obj, evt
);
}
}
#include <QKeyEvent>
#include "TextProcessor.h"
bool TextProcessor::eventFilter(QObject *obj, QEvent *evt)
{
if (evt->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(evt);
if (keyEvent->key() == Qt::Key_Return)
{
if (keyEvent->modifiers() == Qt::ControlModifier)
{
qWarning("Ctrl");
emit escapeCharPressed();
return false;
}
else
{
qWarning("Enter");
// emit lineFeed();
return true;
}
}
else
{
return false;
}
}
else
{
return QObject::eventFilter(obj, evt);
}
}
To copy to clipboard, switch view to plain text mode
The case is that when I press Enter Key I got the line in debugging, but the editor is still closing, so I guess the event is still forwarding to the monitored object.
What am I doing wrong?
Thanx a lot in advance.
Bookmarks