Change text of a label in the view class, from another class.

22 views
Skip to first unread message

Antonio F.S.

unread,
Aug 2, 2022, 6:09:10 PM8/2/22
to The Ring Programming Language

Good evening.

Well, I've been trying all afternoon and trying different syntaxes but nothing: I haven't been able to change the text in a label of the view class, I can change the text from another class. So, after also looking at some sources in Ring Examples, either what I'm looking for isn't there, or I haven't been able to find it. So I explain it here:

In the view class and inside the win object:


In the controller class:


In another class:


Best regards.

Antonio F.S.

Ilir

unread,
Aug 2, 2022, 7:46:41 PM8/2/22
to The Ring Programming Language
Hello,

you have at least two options

1. add to comprobacion function additional argument passing view,  e.g.

    func comprobacion(v, o)
        v.Label1.setText("Hello")

2. make use of the OOP 

class Entradas
    Label1
      func comprobacion(o)
        Label1.setText("Hello")
     ...

class Ventana1RingController from windowsControllerParent
    ...
    oIr2 = new Entradas { Label1 = oView.Label1 }

Ilir

unread,
Aug 3, 2022, 2:38:33 AM8/3/22
to The Ring Programming Language
Hello,

next two options

1. Use class constructor to pass view

class Entradas
    oView
    func init v
        oView = v

class Ventana1RingController from windowsControllerParent

    oView = new Ventana1RingView
    ...
    oIr2 = new Entradas(oView)


2. Use objects library specific to Qt (you can only pass controller)

load "objectslib.ring"

class Entradas from WindowsControllerParent
    func init p
        setParentObject(p)

    func comprobacion(o)
        parent().oView.Label1.setText("Hello")

class Ventana1RingController from windowsControllerParent

    oView = new Ventana1RingView
    ...
    oIr2 = new Entradas(this)

Antonio F.S.

unread,
Aug 3, 2022, 7:18:35 AM8/3/22
to ring...@googlegroups.com


Hello.

First of all, thank you very much again, Ilir.

Re-thinking according to your first example, I followed the path traced previously regarding passing a second parameter (the Label1 object) to the ' check ' method of the ' Inputs ' class. Then and as you point out with your initial suggestion, it was a matter of imitating a little the ' innerHtml ' but with setText, prior "signalling" with the object received by sending the text string to change.

I all afternoon yesterday and today, with a little guidance from you it was solved in five minutes or less :-) :-) :-)

I'm continuing my studies at Ring.
Best regards.
Antonio F.S.





---------------------------------------------

El 3/8/22 a las 1:46, Ilir escribió:
--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/a9ef53d6-5780-439d-a34b-bf198513fd49n%40googlegroups.com.

Ilir

unread,
Aug 3, 2022, 9:41:44 AM8/3/22
to The Ring Programming Language
Hello,

You're Welcome. Good choice, BTW.

Greetings,
Ilir

Reply all
Reply to author
Forward
0 new messages