1.Widget无边框,窗口透明:
this->setWindowFlags(Qt::Window| Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground, true);
2.Dialog无边框,窗口透明:
this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground, true);
3.QQuickWidget窗口透明:
this->setClearColor(QColor(Qt::transparent));
this->setAttribute(Qt::WA_TranslucentBackground, true);
在QQuickWidget中,QML里也需要设置color为透明:
color: "transparent"
或者:
color: "#00000000"
4.QWidget窗口叠加透明:
this->setAttribute(Qt::WA_AlwaysStackOnTop);
this->setClearColor(QColor(Qt::transparent));
this->setAttribute(Qt::WA_TranslucentBackground,
以上。
网友评论