Transparent QML applications

Here is the code to make a QDeclarativeView based application transparent.

#include
#include

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QDeclarativeView view;
view.setSource(QUrl::fromLocalFile(“myqmlfile.qml”));
view.setAttribute(Qt::WA_TranslucentBackground);
view.viewport()->setAutoFillBackground(false);

view.show();
return a.exec();
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.