The WKC JavaScript Object
The _uc_WebKitControl invokes a QObject using the QT-Webkit bridge . This Object provides signals and slots that may be used to access functionality:
- Signals
Signals provide data from the C++ side of the object and need to be connected to a JavaScript function ( see example )
- signal setControlData(const QString&)
This signal is emitted when the QtWebkit Frame has finished loading ( loadFinished() )
- signal infoException(const QString&)
This signal is emitted when a exception occurred during the processing of the control property. The string contains the what() of the exception.
- Slots
Slots are used to pass data from JavaScript to C++
- slot loaded()
Reads the data from the associated property and sends its value(s) as string using the setControlData signal
- slot message(const QString&)
Sends a message to the control context that can be handled using the doMessage() handler.
- slot refresh()
reload the url. (associated with Ctrl+R)
- slot setup()
Add the wkc object to the JavaScript window object (internal)
wkc.setControlData.connect(wkc,wkcj.setControlData);
wkc.infoException.connect(wkc,wkcj.infoException);
(function(){
wkcj = {
self:null
, init:function(){
wkjc.self = this;
}
, setControlData: function(data){
var obj = JSON.parse(data);//'{"name":"1"}');
}
, infoException: function(message){
//do not alert!
$('#infoarea').update(message);
}
};
})();