I have QQuickView window for QML, and it has QWindow as parent window, so the QQuickView is inside the parent window. I would like to get this QQuickView window as transparent, but when I set it to transparent as child window for QWindow, it is black. But if it is as own window, it is totally transparent as should.
There is code example:
int main (int argc, char *argv[]) {
QGuiApplication app(argc, argv);
QWindow window;
window.resize(800, 640);
window.show();
QQuickView view;
view.setSource(QUrl::fromLocalFile("qml/main.qml"));
QSurfaceFormat surfaceFormat;
surfaceFormat.setAlphaBufferSize(8);
view.setFormat(surfaceFormat);
view.setClearBeforeRendering(true);
view.setColor(QColor(Qt::transparent));
view.setParent(&window);
view.show();
return app.exec();
}
And main.qml:
import QtQuick 2.0
Rectangle {
width: 300
height: 300
color: "#00000000"
Text {
id: label
color: "red"
text: "TEST"
y: 240
x: 160
}
}
I use Linux desktop with Qt 5.0.1 and Qt Quick2. It doesn’t matter if the parent window is also a QQuickView instead of QWindow.
↧