Hello, I use QWebEngineView for render my HTML page and QWebChannel for 
communicate with my JS code. I can pass QVariant type into JS code as signal 
parameter or function return value. But I need to pass custome class object. I 
wrote the class and inherit it from QObject like this:#include <QObject>class 
test : public QObject{Q_OBJECTpublic:test() : QObject(nullptr) {}test(const 
test&) : QObject(nullptr) {}test(QObject *parent) : QObject(nullptr) {};int a;
int b;
};Q_DECLARE_METATYPE(test);
than I registered type as:qRegisterMetaType<test>();and emit signal:test t;t.a 
= 666;t.b = 454;emit home_page_controller.MySignal(t);In JS code I connect to 
signal ant try to show received 
data:document.addEventListener("DOMContentLoaded", function (){new 
QWebChannel(qt.webChannelTransport, function 
(channel){window.home_page_controller = channel.objects.home_page_controller;   
 window.home_page_controller.MySignal.connect(function(struct)
    {
        alert(struct)
    })
    });
});But instead [Object] I recived null.Next my step - add my structure into 
QVariant:QVariant var;test t;t.a = 666;t.b = 454;var.setValue(t);emit 
home_page_controller.MySignal(var);But null received again. How I can to pass 
custome data into JS code? Thanks.                                        
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to