Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebElement evaluateJavaScript - speed issue
QtWS25 Last Chance

QWebElement evaluateJavaScript - speed issue

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 801 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.
  • M Offline
    M Offline
    maximus
    wrote on last edited by
    #1

    I am trying to optimize some part of my code that run slow with "evaluateJavaScript" lagging the UI a little bit.

    I have tried to put all my evaluateJavaScript into one and process it directly on the QWebFrame, but it's not faster (even slower).
    Is there a way to improve the speed of my calls?

    I haven't moved to QWebEngine as my project is not compatible yet (using msvc2012 and need cookie management)

    @ /// Name
    QWebElement inputNameElement = ui->webView_workouts->page()->mainFrame()->documentElement().findFirst("input[id="name-workout"]");
    QString jsValue = QString("this.value='%1';").arg("");
    inputNameElement.evaluateJavaScript(jsValue);

    /// Plan
    QWebElement inputPlanElement = ui->webView_workouts->page()->mainFrame()->documentElement().findFirst("input[id=\"plan-workout\"]");
    jsValue = QString("this.value='%1';").arg(plan);
    inputPlanElement.evaluateJavaScript(jsValue);
    
    /// Creator
    QWebElement inputCreatorElement = ui->webView_workouts->page()->mainFrame()->documentElement().findFirst("input[id=\"creator-workout\"]");
    jsValue = QString("this.value='%1';").arg("");
    inputCreatorElement.evaluateJavaScript(jsValue);
    
    
    // This is slower that above code, find out why, maybe try with QWebEngine later
    //    QString jsToExecute = "$('#name-workout').val( '' ); ";
    //    jsToExecute += QString("$('#plan-workout').val( '%1' ); ").arg((plan));
    //    jsToExecute += "$('#creator-workout').val( '' ); ";
    //    ui->webView_workouts->page()->mainFrame()->documentElement().evaluateJavaScript(jsToExecute);@
    

    Free Indoor Cycling Software - https://maximumtrainer.com

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maximus
      wrote on last edited by
      #2

      Still would like to know what's the best way to use evaluateJavascript()
      on the page or on the QWebElement individually? Are there best practices?
      Thanks


      Free Indoor Cycling Software - https://maximumtrainer.com

      1 Reply Last reply
      0

      • Login

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