-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.4.0
-
None
-
Qt 5.4, Ubuntu 14.04, OSX 10.10, Chrome browser Version 40.0.2214.111 (64-bit)
When reading docs:
http://doc.qt.io/qt-5/qwebchannel.html#registerObject
I come across a statement:
The properties, signals and public invokable methods of the objects are published to the remote clients.
My understanding is that:
- public data members
- public functions
- signals
- public slots
of the object which is passed to {{void QWebChannel::​registerObject(const QString & id, QObject * object)}} function are available from the remote client via JavaScript (e.g. a browser).
The problem: properties and public methods of QWebChannel registered object are not accessible by the remote client.
To test it out I've used Qt WebChannel Standalone Example. The example uses signals and public slots which work ok. However if I add public data members or public methods, they do not appear in the list of available JavaScript dialog object properties.
My addition to the Dialog class:
... public: int my_public_attr; void my_public_method() {} explicit Dialog(QObject *parent = 0) : QObject(parent) ...
Available JS properties are shown in the attachment. You can see that sendText as well as receiveText are available, but my_public_attr and my_public_method are not.
Maybe it is my misunderstanding of the docs in which case I would kindly ask you for clarification. Could you provide an example of how to make properties, signals and public invokable methods usable from the JavaScript end?
Thanks,
Tom