qtdeclarative/tools/qmljsrootgen
Fabian Kosmale 8effdd97d9 Expose XMLHttpRequest to qmltypes
In QML, one can use XMLHttpRequest. Not so with a plain JS engine. The
reason for that lies in the fact that a JS engine did not have any
network access, because all network functionality was in the type
loader, and the type loader was coupled to the QV4::Engine.
This has changed in d2bc4a4330, but we
stil don't expose XMLHttpRequest to a plain QJSEngine.

Nevertheless, it conceptually lives in the global object, and we need to
collect information about it to enable code completion and linting.

Consequently, expose a function in QV4::Engine, which allows us to
manually trigger the registration, and call it in qmljsrootgen.

Going forward, we should arguably have a QJSEngine::Extension for
XMLHttpReuqest, after which we could remove the hack.

Note that as before, qmljsrootgen prints a few warnings, because we call
functions in contexts in which they must not be called. As before, we
ignore this for now.

As a side-effect, this adds a few more entries to the qmltypes file for
new entries on the global Qt object.

Task-number: QTBUG-137075
Pick-to: 6.10
Change-Id: I21e9d62bf075e8d4356db8f357502feb927717e7
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-07-22 10:18:31 +02:00
..
CMakeLists.txt Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-09-07 17:01:30 +02:00
main.cpp Expose XMLHttpRequest to qmltypes 2025-07-22 10:18:31 +02:00