简体   繁体   English

QML:如何创建半透明/半透明的WebView元素?

[英]QML: how to create semi-transparent/ translucent WebView element?

I wonder how to create a WebView element that would be transpalent (like in terms of transparent window...) I try something like: 我想知道如何创建一个透明的WebView元素(例如透明窗口...),我尝试执行以下操作:

       Rectangle {
           id: webBrowser
           width: 100; height: 100
           color: "red"
           WebView {
               html: "<style>body,html{background:transparent;background-color: rgba(1,255,0,0.5;)} </style><p>Hello</p>"
             //     preferredWidth: 50
              //    preferredHeight: 50
anchors.fill: parent

           }
       }

but it seems not to help=( What shall I do to make WebView transparent? 但似乎没有帮助=(我应该怎么做才能使WebView透明?

You need to set the opacity of the WebView itself, not just the HTML content: 您需要设置WebView本身的不透明度,而不仅仅是HTML内容:

WebView {
   opacity: 0.5;
   html: "<style>body,html{background:transparent;background-color: 
         rgba(1,255,0,0.5;)} </style><p>Hello</p>"
   anchors.fill: parent
   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM