Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render focus indicators in an offscreen window?

Tags:

c++

qt

qml

qtquick2

I'm trying to implement a custom user interface in virtual reality using Qt. I'm using QQuickRenderControl to render some UI defined in QML into an OpenGL framebuffer.
The resulting texture is drawn onto a quad in my custom OpenGL scene. Mouse events are simulated using the motion controllers.

This all works great, but I cannot render the UI in an "active" or "focused" style. For example, if I activate a text field, there is no cursor and no blue outline, because the offscreen window (a QQuickWindow) is not considered an active window. It's never actually shown on the desktop - it only exists in memory.

If I force the window to be shown on the desktop and make it the front window of the application, then the active text field is rendered correctly with the focus outline and the cursor within the VR scene. However, I would like to avoid having to show this window on the desktop (it renders as an empty white window).

Is there a way to force a QQuickWindow to render as if it was the front window, even if that's not the case?

like image 439
Jawap Avatar asked Mar 20 '18 10:03

Jawap


Video Answer


1 Answers

m_quickWindow->setX(-m_quickWindow->width());
m_quickWindow->setY(-m_quickWindow->height());
m_quickWindow->setFlag(Qt::SplashScreen);
m_quickWindow->show();

It's was okay for Qt 5.11

m_quickWindow->setOpacity(0.f);
m_quickWindow->setFlags(Qt::SplashScreen | Qt::WindowTransparentForInput);
m_quickWindow->show();

Better solution - okay for Qt 5.15

But it doesn't look good.

like image 71
Leo Avatar answered Oct 30 '22 06:10

Leo