How to make a transparent window with Qt Quick 2.0

南笙酒味 提交于 2019-12-07 08:35:52

问题


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?).


回答1:


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.




回答2:


Here's a Qt5 code:

QSurfaceFormat surfaceFormat;
surfaceFormat.setAlphaBufferSize(8);
viewer.setFormat(surfaceFormat);
viewer.setClearBeforeRendering(true);
viewer.setColor(QColor(Qt::transparent));


来源:https://stackoverflow.com/questions/14009549/how-to-make-a-transparent-window-with-qt-quick-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!