Paste in WebEngineView



  • Is paste failing in webengineview a known issue?

    It works in the webengineview nanobrowser example - but there's some sort of 'action' mapping in that sample (that I do not know if it is necessary or not.)

    Is this something I need to manually add to my qml code in order for paste/copy to work?


  • Moderators

    @VRHans This barebones example works. Nothing extra is added.

    QtWebEngine::initialize();
    
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
    

    main.qml

    WebEngineView {
        anchors.fill: parent
    }
    

    Which Qt version/OS are you using ?



  • 5.7

    It doesn't work on OSX until I do what the nanobrowser sample does - which is hand connect the keyboard shortcuts to the web actions on the view.


  • Moderators

    @VRHans Ok. Which keyboard shortcut did you use for copy/paste ?



  • @p3c0

    I just used a subsection from the sample's BrowserWindow.qml:

        Action {
            shortcut: StandardKey.Copy
            onTriggered: currentWebView.triggerWebAction(WebEngineView.Copy)
        }
        Action {
            shortcut: StandardKey.Cut
            onTriggered: currentWebView.triggerWebAction(WebEngineView.Cut)
        }
        Action {
            shortcut: StandardKey.Paste
            onTriggered: currentWebView.triggerWebAction(WebEngineView.Paste)
        }
        Action {
            shortcut: "Shift+"+StandardKey.Paste
            onTriggered: currentWebView.triggerWebAction(WebEngineView.PasteAndMatchStyle)
        }
        Action {
            shortcut: StandardKey.SelectAll
            onTriggered: currentWebView.triggerWebAction(WebEngineView.SelectAll)
        }
        Action {
            shortcut: StandardKey.Undo
            onTriggered: currentWebView.triggerWebAction(WebEngineView.Undo)
        }
        Action {
            shortcut: StandardKey.Redo
            onTriggered: currentWebView.triggerWebAction(WebEngineView.Redo)
        }
    

  • Moderators

    @VRHans Can you try setting javascriptCanAccessClipboard ?



  • @p3c0 As a replacement for the code above (which works)?


  • Moderators

    No. In the code that I posted.



  • @p3c0 as a fallow up I tried the property you are talking about and it made my app crash (just the addition of that line). I don't know if this is a bug but it happened on qt 5.7.1.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.