Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. QWebEngineView runJavaScript() problem
Forum Updated to NodeBB v4.3 + New Features

QWebEngineView runJavaScript() problem

Scheduled Pinned Locked Moved Unsolved QtWebEngine
1 Posts 1 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pavlya
    wrote on 21 Feb 2016, 18:07 last edited by
    #1

    Hello all.

    I faced with some strange behavior in QWebEngineView.
    I have a loaded page in QWebEngineView object witch has 'group0' element.
    I run next script:

    ...
    QString script = "document.getElementsByName('group0');";
    page()->runJavaScript(script, [](const QVariant &v) {qDebug() << v;});
    ...
    

    It prints

    QVariant(QVariantMap, QMap())
    

    But now I need value of first element of 'group0' (or array with several values). I tried to run script:

    QString script = "var elems=document.getElementsByName('group0');" 
                     "system.log(elems[0].value);";
    page()->runJavaScript(script, [](const QVariant &v) {qDebug() << v;});
    

    But I got

    QVariant(Invalid)
    

    Documentation says

    Runs the JavaScript code contained in scriptSource.
    
    When the script has been executed, resultCallback is called with the result of the last executed statement.
    
    Note: resultCallback can be any of a function pointer, a functor or a lambda, and it is expected to take a QVariant parameter.
    

    Could you say me how can I return result of the last executed statement from script to callback.

    Thank you.

    1 Reply Last reply
    0

    1/1

    21 Feb 2016, 18:07

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved