Qt中设置QML窗体无边框和背景透明

来源:互联网 发布:软件测试51testing 编辑:程序博客网 时间:2024/06/07 22:37

主要代码在(main()函数中)如下:

    //设置窗体无边框
    view.setWindowFlags(Qt::FramelessWindowHint);
    //设置整个窗体背景为透明
    view.setAttribute(Qt::WA_TranslucentBackground);
    view.setStyleSheet("background:transparent;");

这里的view可以是:

QDeclarativeView view ;

或者

QmlApplicationViewer view;


上述代码中,设置背景为透明的,必须有(当然也是根据不同需求不一样)这两句,不然的话,背景还是会有白色。