【问题标题】:Set specific color in qt5 webview transparent在qt5 webview中设置特定颜色透明
【发布时间】:2014-07-15 21:45:01
【问题描述】:

我正在开发基于 Qt5 webview 的应用程序,我需要使 webview 中的特定颜色透明或具有 alpha 通道。 例如,加载到 webview 中的网页可能具有带背景颜色的全屏 div(大多数情况下为黑色,但可能是另一种颜色)。我需要使这种颜色(带有 webview 本身)是半透明的。申请表上的所有其他元素都应通过此 web 视图可见。

【问题讨论】:

    标签: qt5 transparent qwebview chromakey


    【解决方案1】:

    我想我理解你的问题,你想让 WebView 具有半透明背景(或其他东西)。

    你可以尝试去掉webview的背景,使用这个(来源:https://gist.github.com/anonymous/103126):

    QPalette palette = ui->webView->palette(); //Get webView palette
    palette.setBrush(QPalette::Base, Qt::transparent);
    ui->webView->page()->setPalette(palette); //Set transparent palette
    ui->webView->setAttribute(Qt::WA_OpaquePaintEvent, false);//Remove opaque
    

    在你的 css 文件中(到 html 中),使用这个:

    <html>
    <head>
    body {
       background-color: rgba(255, 0, 0, 0.2);//Edit "0.2" to obtain the opacity needed.
    }
    </head>
    <body>
    Something...
    </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-14
      • 2012-01-20
      • 2017-11-02
      • 1970-01-01
      • 2018-05-23
      • 2016-02-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多