美文网首页
Qt窗口透明

Qt窗口透明

作者: _compass | 来源:发表于2022-03-09 14:03 被阅读0次

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, 

以上。

相关文章

网友评论

      本文标题:Qt窗口透明

      本文链接:https://www.haomeiwen.com/subject/rgeezltx.html