Qt窗口透明

2022-03-09  本文已影响0人  _compass

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, 

以上。

上一篇 下一篇

猜你喜欢

热点阅读