Project

General

Profile

Actions

Support #6777

closed

Support request

Added by Momo LALMI almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
11/28/2018
Due date:
% Done:

0%

Estimated time:

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

Actions #1

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.

Actions #2

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 ?

Actions #3

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);
Actions

Also available in: Atom PDF