Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Web Engine/Channel communication fail using signals
Forum Updated to NodeBB v4.3 + New Features

Web Engine/Channel communication fail using signals

Scheduled Pinned Locked Moved Unsolved QtWebEngine
1 Posts 1 Posters 1.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PayanAx
    wrote on 11 Jan 2017, 15:21 last edited by
    #1

    Hi,

    I use a signal to send an object from the C++ to my web page (in the WebEngine) using the WebChannel.
    The signal is correctly triggered, however, the object is always null.
    There are no errors in the console.

    Here is the piece of code:

    index.html

    new QWebChannel(socket, function(channel) {
                            window.paymentModule = channel.objects.paymentModule;
                           
                           ...
                           
                           paymentModule.currentStatus.connect(function(status)  {
                                console.log("Status");
                                console.log(status);
                                ...
                            });
    };
    

    The class used as paymentModule in javascript:

    class WebDevice : public QObject
    {
        Q_OBJECT
    
    public:
        WebDevice(const QString &comPort, QObject *parent = 0);
    
    signals:
         void currentStatus(const Status &status);
    
    private slots:
         void onStatusUpdate(const Answer::Status &);
         ...
    };
    
    
    Q_DECLARE_METATYPE(PaymentModule::iUP250::Answer::Status)
    Q_DECLARE_METATYPE(Status)
    
    WebDevice::WebDevice(const QString &comPort, QObject *parent)
     {
    
        qRegisterMetaType<PaymentModule::iUP250::Answer::Status>();
        qRegisterMetaType<Status>("Status");
        connect(&_device, &Layer::Application::statusChanged, this, &WebDevice::onStatusUpdate, Qt::QueuedConnection); // Qt::DirectConnection
     }
    
     void WebDevice::onStatusUpdate(const Answer::Status &status)
    {
         emit currentStatus(Status());
    }
    

    All types are registered. Status class as a copy constructor, default constructor and destructor.
    It doesn't matter if Status inherit QObject or not, the result is the same.

    Sadly there isn't any error in the console. That's why I'm a bit stuck and look for help.
    Does anyone have an idea of what I could be doing wrongly ?

    Thanks,

    1 Reply Last reply
    0

    1/1

    11 Jan 2017, 15:21

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved