Hello Ring Team,
I am pleased to announce that our library now supports calling QML functions directly as methods inside the root QQuickWidget / QQuickView and within components.
There is currently one limitation to keep in mind: Function names must be unique. You cannot define a function with the same name in both a component and the main QML file; you must use different names for them.
Here is a simple example demonstrating this feature:
Output:
Best wishes,
Mohannad
Hello Mahmoud,
"In the future, you can have more natural API and avoid limitations by treating QML code as (Templates), i.e. as we do with HTML Templates in WebLib
By having a template() function (written in Ring), you could process the QML code as string and do modifications before usage
Such modifications could determine, which functions to call, rename functions, add/change code, etc."
Response:
Of course. I'm currently using addMethod, but I'm running into a "method redefinition" error, which is the cause of this limitation. I recall you mentioned in the Arabic tutorials that addMethod adds the method to the whole class, as documented. The immediate solution is to use callQMLFunc(cFuncNam, aParams) if we have functions with the same names.
"Your library could provide more than one way to do things, as WebLib does which provides API using functions for generating HTML, another API using classes, and support HTML templates too."
Response:
I have several plans for the library; it feels like this project has opened the door to a new journey.
"As a start, you could focus on functionality, sharing an early release with some samples, then you could improve the library along the time through new versions/releases."
Response:
That is exactly what I'm doing. The library currently depends on guilib and can be embedded in GUI programs. For instance, I'm using it now for a scientific research collaboration between the University of Mosul and the University of Dortmund, Germany, where I used the library with QQuickWidget to enable certain QML features.
"It could be a start for a framework for developing Mobile apps using Ring based on QML instead of Qt Widgets."
Response:
Certainly. My current plan involves two versions:
ringQMLCore: A version that works with QQuickWidget/QQuickView and integrates with guilib.ring.
ringQML: The official, feature-rich library (which will not require guilib.ring). This version will use QCoreApplication for the event loop, QQuickView for the window (supporting mobile and WebAssembly), and incorporate essential RingQt classes (like core and network classes).
I will share some apps and samples in the near future. Additionally, I am planning to use Qt6 for this library, as it is more powerful and stable for both mobile and WebAssembly.
Best wishes,
Mohannad