[Development] How to set QQuickView TranslucentBackground
Samuel Rødal
samuel.rodal at nokia.com
Thu Mar 8 15:39:07 CET 2012
On 03/08/2012 02:24 PM, ext hailong geng wrote:
> Hi
> Thank you for your reply. What do you mean by "setting a non-zero
> alpha in the QSurfaceFormat of the QWindow"? I tried touse the following
> code but still get black background.
> QQuickViewcanvas;
>
> QSurfaceFormat surfaceFormat;
>
> surfaceFormat.setAlphaBufferSize(1000);
Should probably be surfaceFormat.setAlphaBufferSize(8); as I'm not sure
if it bails out when it can't find a configuration with at minimum the
requested buffer size at the moment.
> canvas.setFormat(surfaceFormat);
>
> canvas.setClearBeforeRendering(true);
>
> canvas.setClearColor(QColor(Qt::transparent));
>
> canvas.setWindowFlags(Qt::FramelessWindowHint);
Looks good, I'd expect this to give the expected outcome. Try the alpha
buffer fix, and if it still doesn't work please file a bug. It might be
that noone has tested this properly with Qt 5 yet.
> Would you please tell me something about how does Qt Quick2 render the
> scene? I think it doesn't render opengl into video memory
> directly because if so, when I drag one other window above the qml
> scene, it should flash :) So does it use QGLPixelBuffer class for that?
> I am new to opengl and scene graph, I am not clear with the work flow.
> But I really want to make the QML View Translucent, this will be very
> cool ^_^
It does render directly to the window (although potentially in a
separate thread), not sure what kind of flashing you expect, that's
mostly solved by compositing window managers.
--
Samuel
More information about the Development
mailing list