QApplication::focusWidget() and QApplication::focusObject()
-
What's the difference other than the return type?
In addition, in my app the focusWidget() is returning 0 and focusObject() is returning an object to QML textinput. How can that be that both are not returning a pointer? I am using Qt5 and earlier in Qt4.8 focusWidget() used to work OK. I am trying to use QApplication::sendEvent with focusWidget() return value as the first parameter but it crashes because focusWidget() returns 0. If I use focusObject() then the keyEvent is not delivered.
-
afaik in QT5 there is only QGuiApplication::focusObject () and QWindow::focusObject which would both differ from the functions in Qt 4.8 that the will return the QObject that will be the final receiver of events tied focus (looking at the documentation..) whereas focusWidget() in bith cases (Qt5 and 4.8) will return the widget which has keyboard input focus or 0 if no widget in your application has the focus.
i think the way to go should be to test if you got a 0-pointer and handle it correctly
hope that will help you
kind regards
christian