Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QWebElement evaluateJavaScript - speed issue

    General and Desktop
    1
    2
    714
    Loading More Posts
    • 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
      maximus last edited by

      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 Reply Quote 0
      • M
        maximus last edited by

        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 Reply Quote 0
        • First post
          Last post