How to make a transparent window with Qt Quick 2.0

2019-05-05 01:48发布

I've already know how to make a transparent window with Qt Quick 1.0.But I started to use Qt 5.0 and Qt Quick 2.0 recently and didn't know how to do with it.

setAttribute setWindowFlags setStyleSheet

The functions above are removed from the QtQuick2ApplicationViewer(QQuickView). So I wonder whether I can make a transparent window with Qt Quick 2 or not (is it because that it's based on OpenGL?).

2条回答
祖国的老花朵
2楼-- · 2019-05-05 02:14

Look here for a possible solution:

http://code.google.com/p/quickwidget/

But, with Qt 5.3, it is possible to use the built-in QQuickWidget class.

查看更多
欢心
3楼-- · 2019-05-05 02:32

Here's a Qt5 code:

QSurfaceFormat surfaceFormat;
surfaceFormat.setAlphaBufferSize(8);
viewer.setFormat(surfaceFormat);
viewer.setClearBeforeRendering(true);
viewer.setColor(QColor(Qt::transparent));
查看更多
登录 后发表回答