Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. What is the use of QQuickWindow:: setDefaultAlphaBuffer(bool use Alpha)
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ottobert
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved