QEvent in qml
-
Thanks Michael
I implemented wrappers similar to the ones in qdeclarativeevents_p.h but when I try to use them in my qml I get this error:
QMetaProperty::read: Unable to handle unregistered datatype 'QMLKeyEvent*' for property 'QDeclarativeBoundSignalParameters::event'
I register the QMLKeyEvent class with this call:
@
qmlRegisterType<QMLKeyEvent>();
@And at the end of my header file that contains the QMLKeyEvent class I put:
@
QML_DECLARE_TYPE(QMLKeyEvent)
@Is there something else I need to do to register this type?
-
I believe I'm using Qt 4.7.1.
My QML code looks like this:
@
UserEventFilter {
id: userEventFilter;onKeyPressed: {
console.log(event.text);
}
}
@UserEventFilter code looks like this:
@
bool UserEventFilter::processKeyPress(QEvent *event) {
QMLKeyEvent ke(*static_cast<QKeyEvent *>(event));
ke.setAccepted(false);emit keyPressed(&ke);
emit userEventOccurred();return ke.isAccepted();
}
@I'm going to upgrade to Qt 4.7.2 and see what happens.