Support #6777
closedSupport request
0%
Description
Hello,
I would like to use a WLabel to display local time (in standard 24 hours format).
I am using a WTimer to update the WLabel text and it is working.
Is there a more efficient solution (Web Browser javascript, ...etc.) to avoid client-server roundtrip ?
thank you in advance for you help
Updated by Roel Standaert almost 6 years ago
You'd have to write your own JavaScript and run it client-side indeed, if you want to avoid the roundtrip. WTimer
is fired client side, so you can actually directly connect JavaScript code (or a JSlot
) to it. You'll probably need to use jsRef()
to get the appropriate string that identifies your WLabel
.
Updated by Momo LALMI almost 6 years ago
Thank you for your feedback.
Can you add a small example that explains how to use and connect JSlot (or javascript code) with WTimer event ?
Updated by Roel Standaert almost 6 years ago
- Status changed from New to Closed
WTimer
emits the timeout()
signal, so you can just connect JavaScript as a string:
timer->timeout().connect("function(){console.log(\"Your JavaScript here\");}");
Or create a JSlot and connect that:
JSlot slot(parent); // make sure this lives long enough, e.g. as a member of the parent widget, or add it as a child of the parent widget.
slot.setJavaScript("function(){console.log(\"Your JavaScript here\");}");
timer->timeout().connect(slot);