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:

        @QQuickWindow::setDefaultAlphaBuffer(true);
    

    QQuickView view;

    view.setColor(Qt::transparent);
    view.setSource(QUrl::fromLocalFile("test.qml"));
    view.setResizeMode(QQuickView::SizeRootObjectToView);

    bool b = view.hasDefaultAlphaBuffer();

    QWidget* p = QWidget::createWindowContainer(&view, NULL, Qt::FramelessWindowHint);
    p->setAttribute(Qt::WA_TranslucentBackground);
    p->show();@

    and here is my test.qml:

    @import QtQuick 2.0

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

    Rectangle
    {
    x: 50;
    y: 50;
    width: 100;
    height: 100;
    color: "blue";
    }
    }@

    So what is the use of this function?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.