Connecting JavaScript files to other JavaScript files in a Qt / QML project
In the framework of the project on QML there is an opportunity not only to connect JavaScript files in QML files, but also in other JavaScript files. The syntax for connecting these files will be similar to that used in QML files.
For example, a variant of connecting a JavaScript file in a QML file
Then, how to connect a JavaScript file to another JavaScript file will differ only by the presence of a dot before this line
Example
We are given a small project, in which there are the following files
main.qml
first.js
second.js
The next task is to connect first.js to main.qml and call a function from this JavaScript file, which will call the function from second.js , which will be connected in the file first.js .
main.qml
second.js
This file has only a function for outputting the Second line to the console. This function will need to be called in the first.js file
first.js
Conclusion
As a result, when the button is pressed, the function from the file first.js will be called, which will output its message to the console and call the function from file second.js .
The following message will be displayed in the console:
Last updated