[SOLVED] Set the focus on the viewport of the QDeclarativeView
I have a QGlWidget and I have set it as the viewport of the
The widget is basically a QGLWidget inheritance, subclass.
The QGLWidget gets the QDeclarativeView as the parent during the
object construction. (this is how I handle in my local clone)
I have tried to call the d->widget->setFocus() here:
I have also tried to call the view->setFocus() here
I also use event filtering, but that should hopfully not cause any issue:
Everything works just fine apart from the focus setting meaning that I
cannot handle any input events, keystrokes on that widget. I have
other standalone applications resembling the functionality and the
focus works just fine there for the QGLWidget.
125th: setCentralWidget( d->widget ); and 149th:
d->widget->setFocus() lines. In the latter case, I did not use any
QDeclarativeView, but QMainWindow.
The viewport doesn't receive any events, basically. This is basic functionality of QAbstractScrollArea. It installs an event filter, turning all events into QAbstractScrollArea::viewportEvent. Actually viewportEvent is protected virtual. So I think I should be able to use that to route things to wherever I needed them. or ?
Please help, when you can and have time. :-) Thank you in advance!
Could you please tell us how you solved it? That might be useful for future reference.
Sure, but you can check out the files aforementioned anytime or the commit message.
I stopped using the QGLWidget subclass as the viewport and I change the index in a QStackedWidget when I play or stop the game meaning that the default visible widget is the QDeclarativeView and when I click on the Play game in that screen, the game starts being played and I change the index to the QGLWidget inside the QStackedWidget and vica versa when I stop playing the game.