Nominate our 2022 Qt Champions!

What is the use of QQuickWindow:: setDefaultAlphaBuffer(bool use Alpha)

  • In Qt 5.1.0 documentation it says

    bq. void QQuickWindow::setDefaultAlphaBuffer(bool useAlpha) [static]
    useAlpha specifies whether to use alpha transparency on newly created windows.

    bq. In any application which expects to create translucent windows, it's necessary to set this to true before creating the first QQuickWindow, because all windows will share the same QOpenGLContext. The default value is false.

    I have used this function to create a transparent background with a QQuickView, However it didn't change anything (on Windows 7) as far as I can see, here is my code:


    QQuickView view;


    bool b = view.hasDefaultAlphaBuffer();

    QWidget* p = QWidget::createWindowContainer(&view, NULL, Qt::FramelessWindowHint);

    and here is my test.qml:

    @import QtQuick 2.0

    width: 300;
    height: 300;
    color: "transparent"

    x: 50;
    y: 50;
    width: 100;
    height: 100;
    color: "blue";

    So what is the use of this function?

Log in to reply