0

Currently I'm running a HTML/Javascript page inside a QWebEngieView. After the initialization I want to add further JS code via the QWebChannel. Through this channel javascript code is inserted as well before the application is launched and everything (data is displayed as well as callbacks for events are called) works as expected.

After the application is launched every newly registered object through the QWebChannel causes the following message:

Registered new object after initialization, existing clients won't be notified!

The object is created perfectly, except the event callbacks, but this is probably due to the error message, that existing clients won't be notified.

Reading through documentation of QWebChannel as well as further problems found in repositories (e.g. https://github.com/skylarkdrones/pyqtlet/issues/29#issuecomment-799662856), it seems like that you only can register objects before client initialization.

Are there any options on how to create objects through QWebChannel after client initialization? Is there an option to reload/re-initialize the Client, so it receives updates of newly registered objects?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
JaWeilBaum
  • 67
  • 1
  • 1
  • 4
  • 1
    That is a limitation of pyqtlet accepted by the author – eyllanesc Oct 03 '21 at 16:32
  • @eyllanesc I know! But this question is more relating to: "How to register objects to QWebChannel after initialization" – JaWeilBaum Oct 03 '21 at 16:35
  • 1
    The QObjects must be registered before loading the url, that is a well-documented restriction on the part of Qt so you must comply with that rule. So the answer is you can't, at least it's not recommended. – eyllanesc Oct 03 '21 at 16:41
  • A clear proof of what I indicate is the same error message, if the message could be said otherwise or there would be no message. – eyllanesc Oct 03 '21 at 16:58
  • 2
    @JaWeilBaum Your question should really be: how do I restructure my application so that I don't need to register objects after initialisation? – ekhumoro Oct 03 '21 at 20:06

0 Answers0