/*
说明:调用qwebchannel.js 的应用js
qwebchanneltest.js
*/
$.extend({
testexentd:function()
{
new QWebChannel(qt.webChannelTransport,function(channel)
{
//<!--aa js调用QT Demo -->
var jsqtBridge =channel.objects.jsqtbridgeobj;
window.foo=jsqtBridge;
jsqtBridge.jscallqt();
}});
},
loadXXX01Data:function()
{
new QWebChannel(qt.webChannelTransport,function(channel)
{
jsqtBridge =channel.objects.jsqtbridgeobj;
jsqtBridge.bdXXX01Data(function(content){
console.log(content);
alert(content);
});
},
loadXXX02Data:function()
{
new QWebChannel(qt.webChannelTransport,function(channel)
{
jsqtBridge =channel.objects.jsqtbridgeobj;
jsqtBridge..bdXXX02Data(function(content){
console.log(content);
alert(content);
});
}
,
loadXXX03Data:function()
{
new QWebChannel(qt.webChannelTransport,function(channel)
{
jsqtBridge =channel.objects.jsqtbridgeobj;
jsqtBridge.bdXXX03Data(function(content){
console.log(content);
alert(content);
});
}
......
}
在QT与js+html+ qwebchannel 进行开发时,尤其大量方法同时使用,总会莫名其妙发生如下错误,但是调用单个方法偶尔又是好的,
js: Uncaught TypeError: channel.execCallbacks[message.id] is not a function
js: Uncaught TypeError: channel.execCallbacks[message.id] is not a

这篇博客主要讨论了在使用QWebChannel进行QT与js+html交互时遇到的错误,即当大量方法同时使用时,可能出现'Uncaught TypeError: channel.execCallbacks[message.id] is not a function'的问题。作者分析认为这可能是由于QWebChannel不支持过多实例化导致的。为了解决这个问题,提出了采用全局变量和初始化方法的策略,确保只有一个QWebChannel实例,并在每个方法调用前检查和初始化。此外,还给出了具体的实现代码示例。
最低0.47元/天 解锁文章
3960

被折叠的 条评论
为什么被折叠?



