Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebChannel pass QObject from JS
Forum Updated to NodeBB v4.3 + New Features

QWebChannel pass QObject from JS

Scheduled Pinned Locked Moved Unsolved General and Desktop
webchannelpass qobjectjavascript
1 Posts 1 Posters 1.4k Views
  • 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.
  • K Offline
    K Offline
    kDohmen
    wrote on last edited by kDohmen
    #1

    Hello,

    is it possible with a webchannel to pass objects (QObject derived) in js?

    To explain it, i habe something like this:
    c++

    class B;
    class A : public QObject
    {
        Q_OBJECT
        public slots:
            void pass_b(const B *b) {...}                     // do something with b
    }
    
    class B : public QObject
    {
        Q_OBJECT
    }
    

    js

    function someFunc()
    {
        var b = {};                                  // ignore how I got a b-object here ;)
        channel.objects.a.pass_b(b);
    }
    

    As I see, a Json-object will be delivered. But when it comes to argument interpretation (QMetaObjectPublisher::invokeMethod) the json-object is passed to a QVariant and is checked if the needed parameter for the called method is QVariant or if the QVariant-object can be converted to the needed type. But a json-object can not be converted to a QObject. There is no check with wrappedObjects if the object is already known.

    PS: I used the qtwebchannel module from the qt5 github repo in dev-branch.

    1 Reply Last reply
    0

    • Login

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