Skip to content
  • 0 Votes
    24 Posts
    13k Views
    JonBJ

    @ShivaHaze
    @ShivaHaze said in 'evaluateJavaScript()' doesn't return any value. (content position on page wanted):

    You are a god to me - Thanks so much!

    I think you might have meant "good" rather than "god" ;-)

    I am very pleased this approach has worked for you. It is potentially useful for me to know for my own work one day. Had I realized you had not tried the "delay" principle earlier, we would have got there quicker.

    The actual implementation of the delay loop is "naughty". It will mean that your application is "running busily" (i.e. using CPU time, potentially blocking other applications) for most of 1 second. If an expert here looks at it, please don't shout at me! Like I said, I got it from elsewhere as "quick & dirty". For your purposes it's probably fine, and we achieved it without you having to do slots & signals which you were not keen on learning at this stage.

    If you feel like you want to improve/experiment, in the same stackoverflow thread have a look at https://stackoverflow.com/a/3756341/489865, leveraging QWaitCondition, whose description sounds like it should have the same effect without the "busy blocking":

    class SleepSimulator{ QMutex localMutex; QWaitCondition sleepSimulator; public: SleepSimulator::SleepSimulator() { localMutex.lock(); } void sleep(unsigned long sleepMS) { sleepSimulator.wait(&localMutex, sleepMS); } void CancelSleep() { sleepSimulator.wakeAll(); } };

    Certainly I would try it. If you copied that class into your code, you would call it (I assume) via:

    SleepSimulator* sleep = new SleepSimulator(); sleep->sleep(1000); delete sleep;

    Now I think you can get down to the real coding you want to do for your application! Best of luck.

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    2 Posts
    1k Views
    McLionM

    Got it solved :-)

    QWebFrame * webGUIframe = qobject_cast<QWebFrame *>(sender()); QWebView * webGUI = (QWebView*)(webGUIframe->parent())->parent(); webGUI->page()->mainFrame()->addToJavaScriptWindowObject("NativeBridge", this);
  • 0 Votes
    1 Posts
    814 Views
    No one has replied