0

我想知道如何创建一个透明的 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

           }
       }

但似乎无济于事=(我该怎么做才能使 WebView 透明?

4

1 回答 1

1

You need to set the opacity of the WebView itself, not just the HTML content:

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
   }
于 2012-04-26T09:20:13.190 回答