2017-06-27 4 views
1

WebEngineViewのコンテンツをQMLで無効にするにはどうすればよいですか?WebEngineView:コンテンツの選択を無効にする

WebEngineView { 
    id: webEngineView 
    width: 600 * contentZoomFactor 
    height: parent.height 
    anchors.horizontalCenter: parent.horizontalCenter 
    zoomFactor: contentZoomFactor 

    onContextMenuRequested: { 
     request.accepted = true; 
    } 
} 
+0

mouseAreaを使用してwebenginview上に透明な四角形を作成してマウスイベントを処理することができます – SourabhKus

+0

コンテンツの選択のみを無効にしたい場合は、URLのクリックなどのその他の機能を有効にします – mroot

答えて

0

JavaScriptを少し注入して、選択を無効にするスタイルを設定することができます。ここで

は例です:

(function() { 
    document.body.style.webkitUserSelect = 'none'; 
    document.body.style.webkitUserDrag = 'none'; 
})(); 

その後UserScriptとしてあなたのウェブページにそのを注入:

WebEngineScript { 
id: disableSelectionScript 
injectionPoint: WebEngineScript.DocumentReady 
sourceUrl: "qrc:/disableUserSelection.js" 
worldId: WebEngineScript.MainWorld 
} 

userScripts: [disableSelectionScript] 

はただ一つの関数とdisableUserSelection.jsというJavaScriptファイルを作成します。それはトリックを行う必要があります。

関連する問題