Results 1 to 2 of 2

Thread: WebEngineeView and key handling

  1. #1

    Default WebEngineeView and key handling

    In code below I have WebEngineView and keys are handled in two ways - in second case, from dynamically loaded component.
    Key handler does not work, in dynamically loaded component, when I am using WebEngineView.

    web.qml
    Qt Code:
    1. import QtQuick 2.0
    2. import QtWebEngine 1.2
    3. Item{
    4. id: root
    5. height: 500
    6. width: 500
    7. WebEngineView {
    8. id: manualWebView
    9. height: 500
    10. width: 500
    11. enabled: true
    12. url: "https://www.google.com/"
    13. }
    14.  
    15. Keys.onReleased: {
    16. console.log("Loaded item captured INSIDE:",
    17. event.text);
    18. }
    19.  
    20. Loader {
    21. id: loader
    22. source: "debug.qml"
    23. focus: true
    24. onStatusChanged: {
    25. if (loader.status == Loader.Ready) console.log('Loaded')
    26. else
    27. console.log("Status changed: "+loader.status )
    28. }
    29. }
    30. }
    To copy to clipboard, switch view to plain text mode 

    debug.qml
    Qt Code:
    1. import QtQuick 2.0
    2. Item {
    3. focus:true
    4. Keys.onReleased: {
    5. console.log("Loaded item captured OUTSIDE:",
    6. event.text);
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    and output is:
    Qt Code:
    1. $ qmlscene web.qml
    2. qml: Loaded
    3. qml: Loaded item captured INSIDE: q
    4. qml: Loaded item captured INSIDE: t
    To copy to clipboard, switch view to plain text mode 

    Second handler(from loader) works properly when I remove WebEngineView.
    Output after removing WebEngineView:
    Qt Code:
    1. $ qmlscene web.qml
    2. qml: Loaded
    3. qml: Loaded item captured OUTSIDE: q
    4. qml: Loaded item captured INSIDE: q
    5. qml: Loaded item captured OUTSIDE: t
    6. qml: Loaded item captured INSIDE: t
    To copy to clipboard, switch view to plain text mode 

    Why key handling does not work in dynamically loaded component when I am using WebEngineView ?
    How can I solve it ?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: WebEngineeView and key handling

    In the cae with the web view it could be that it gets the active focus when instantiated, while the Loader does not.

    You could try making your web.qml top level item a FocusScope instead of Item or you all forceActiveFocus() no the loaded item in onLoaded.

    Cheers,
    _

Similar Threads

  1. handling exceptions in Qt
    By sattu in forum Qt Programming
    Replies: 12
    Last Post: 29th January 2013, 12:57
  2. QML Signal handling
    By nestuser in forum Qt Programming
    Replies: 0
    Last Post: 16th October 2012, 08:03
  3. handling exceptions
    By mohanakrishnan in forum Qt Programming
    Replies: 3
    Last Post: 25th November 2009, 12:33
  4. Bug in MDI handling
    By daren in forum Qt Programming
    Replies: 1
    Last Post: 31st March 2009, 14:13
  5. handling XClientMessageEvent
    By qtdev18 in forum Newbie
    Replies: 8
    Last Post: 15th August 2007, 20:16

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.