2
在Qt 5.1.0的文件,它說函數void QQuickWindow :: setDefaultAlphaBuffer(bool useAlpha)有什麼用?
無效QQuickWindow :: setDefaultAlphaBuffer(布爾useAlpha)
useAlpha指定是否在新創建的Windows使用Alpha透明度。
在其預計創建半透明窗口的任何應用程序,有必要創建這個第一QQuickWindow之前設置爲
真實的,因爲所有窗口將共享相同的 QOpenGLContext。默認值是false。
我已經使用這個功能來創建一個透明背景的QQuickView,但是它並沒有就我所看到任何改變(在Windows 7),這裏是我的代碼:
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();
這裏是我的test.qml:
import QtQuick 2.0
Rectangle
{
width: 300;
height: 300;
color: "transparent"
Rectangle
{
x: 50;
y: 50;
width: 100;
height: 100;
color: "blue";
}
}
那麼這個函數的用途是什麼?