Hi,
I have a subclassed QLineEdit added to a GraphicsScene and a focusInEvent associated to it.
However the focusInEvent is never called. I tried adding an event filter, but without success.
.h
{
Q_OBJECT
public:
myQLineEditClass();
virtual ~myQLineEditClass() {};
protected:
};
class myQLineEditClass : public QLineEdit
{
Q_OBJECT
public:
myQLineEditClass();
virtual ~myQLineEditClass() {};
protected:
void focusInEvent(QFocusEvent *e);
void focusOutEvent(QFocusEvent *e);
bool eventFilter(QObject *obj, QEvent *event);
};
To copy to clipboard, switch view to plain text mode
.cpp:
{
MGlobal
::displayInfo(MQtUtil
::toMString(QString().
sprintf("EVENT FILTER")));
if (event
->type
() == QEvent::FocusIn) {
return true;
}
return QObject::eventFilter(obj, event
);
}
{
MGlobal
::displayInfo(MQtUtil
::toMString(QString().
sprintf("FOCUS IN")));
}
{
MGlobal
::displayInfo(MQtUtil
::toMString(QString().
sprintf("FOCUS OUT")));
}
/.../
myQLineEditClass *qledit=new myQLineEditClass(oneNode);
scene()->addWidget(qledit);
qledit->installEventFilter(oneNode);
bool myQLineEditClass::eventFilter(QObject *obj, QEvent *event)
{
MGlobal::displayInfo(MQtUtil::toMString(QString().sprintf("EVENT FILTER")));
if (event->type() == QEvent::FocusIn)
{
return true;
}
return QObject::eventFilter(obj, event);
}
void myQLineEditClass::focusInEvent(QFocusEvent *e)
{
MGlobal::displayInfo(MQtUtil::toMString(QString().sprintf("FOCUS IN")));
QLineEdit::focusInEvent(e);
}
void myQLineEditClass::focusOutEvent(QFocusEvent *e)
{
MGlobal::displayInfo(MQtUtil::toMString(QString().sprintf("FOCUS OUT")));
QLineEdit::focusOutEvent(e);
}
/.../
myQLineEditClass *qledit=new myQLineEditClass(oneNode);
scene()->addWidget(qledit);
qledit->installEventFilter(oneNode);
To copy to clipboard, switch view to plain text mode
However neither EVENT FILTER, nor FOCUS IN, nor FOCUS OUT are ever called with I double-click on the QLineEdit. How come ?
Thanks.
Bookmarks