[Qt-interest] Off-screen render with QGraphicsView; focus issues?
Penn Taylor
penn.taylor at atdeconsulting.com
Fri Dec 11 22:32:45 CET 2009
Summary: Hidden instances of QGraphicsView cannot be treated as focused
and active in Qt 4.6 but (apparently) could be in Qt 4.5.3. How can this
behavior be mimicked in Qt 4.6?
Detailed explanation:
I'm using a hidden QGraphicsView that contains a QGraphicsProxyWidget to
render to texture and use this directly in an OpenGL app. This is done
with a hidden QGraphicsView because user interaction takes place through
a GL context (and window) owned and managed by another library.
I can get keyboard focus and tab events to propagate correctly, but some
aspects aren't quite right. For example, clicking on a slider in my app
allows the slider to be moved, but does not place the little "selected"
border around the widget as it should. Ditto for tab traversal. This
makes keyboard navigation difficult, because you can never tell which
widget is selected.
I noticed that scene->hasFocus() and view->hasFocus() always return
false, even if I explicitly call setFocus() just before hasFocus(). It
appears calls to setFocus() and activateWindow() do nothing as long as
the window is hidden. I suspect this to be the root of my problem.
So...how can I make the QGraphicsView, scene, etc. act as though they
are visible, active, and focused even when technically they are not?
This all worked fine in Qt 4.5.3 with a very simple event forwarding
mechanism. Tab traversal, selection highlights, etc. all worked with no
trouble and I never bothered to look at activateWindow(), hasFocus() and
the like because everything "just worked". Qt 4.6 has made the event
forwarding trickier, and has introduced the problems mentioned in the
third paragraph. I'm working under the assumption that things worked
with 4.5.3 because I was unknowingly exploiting a bug. Now I need to
know the right way to do it. Or confirmation that Qt 4.6 contains a
regression on this functionality.
Perhaps there needs to be a
Qt::WA_DontShowOnScreenButTreatAsVisibleAndActive attribute that can be
set on windows?
-Penn Taylor
More information about the Qt-interest-old
mailing list