[RingQml] New Feature: Direct QML Function Calls!

50 views
Skip to first unread message

MOHANNAD ALDULAIMI

unread,
Dec 5, 2025, 4:30:46 PM (3 days ago) Dec 5
to The Ring Programming Language

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:


qml: Hi Ring from Qml 
qml: Hi I'm MainComponent, ring version : 1.24

Best wishes,

Mohannad

direct_call.ring

Mahmoud Fayed

unread,
Dec 6, 2025, 1:53:32 AM (2 days ago) Dec 6
to The Ring Programming Language
Hello Mohannad

>> "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."

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.

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.

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.

It could be a start for a framework for developing Mobile apps using Ring based on QML instead of Qt Widgets. 

Greetings,
Mahmoud

MOHANNAD ALDULAIMI

unread,
Dec 6, 2025, 8:11:01 AM (2 days ago) Dec 6
to The Ring Programming Language

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:

  1. ringQMLCore: A version that works with QQuickWidget/QQuickView and integrates with guilib.ring.

  2. 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

Mahmoud Fayed

unread,
Dec 6, 2025, 1:25:18 PM (2 days ago) Dec 6
to The Ring Programming Language
Hello Mohannad

>> "I'm currently using addMethod, but I'm running into a "method redefinition" error, which is the cause of this limitation."

Since the library get the method name as string during definition & calling
It's easy to modify this name and add a tag before it like "ring_method_"
This way you can avoid conflicts.

Greetings,
Mahmoud

Reply all
Reply to author
Forward
0 new messages