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. QWebChannel - emitting a signal from JavaScript
Forum Updated to NodeBB v4.3 + New Features

QWebChannel - emitting a signal from JavaScript

Scheduled Pinned Locked Moved QtWebEngine
2 Posts 2 Posters 2.1k Views 3 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.
  • I Offline
    I Offline
    ileonte
    wrote on last edited by
    #1

    I have an object exposed to JavaScript via QWebChannel. The object has the following signal: Q_SIGNAL void busy();. In C++ I have the signal connected to some slots. I would like to emit the signal from JavaScript (thus calling my C++ slots) however I can't find any way to do it.

    The JavaScript component of QWebChannel (qtwebchannel.js) generates an object for the signal (as seen here) so I can't call it directly. The only work around I've found so far is to have something like this in my C++ object:

    Q_INVOKABLE void signalBusy();
    Q_SIGNAL 	void busy();
    
    void MyClass::signalBusy()
    {
    	emit busy();
    }
    

    and use channel.objects.myObject.signalBusy(); in JavaScript. You can see how this might become rather annoying for objects with lots of signals.

    I guess the question is: is there a better way to do this ?

    1 Reply Last reply
    1
    • K Offline
      K Offline
      kmbar2013
      wrote on last edited by
      #2

      Did you ever find a solution so that you don't have to call a function that then emits a signal? I am running into this problem as well and we have several functions. The closest I've found are examples that only show how to connect a javascript function to a c++ signal.

      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