Skip to content

Latest commit

 

History

History

keera-hails-reactive-qt

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

This is an experimental layer for Qt as reactive values.

So far only buttons clicks and line edit texts have been added. A quick example: given two line edits (text fields) called l1 and l2, and a button called tb, we can connect them with the following code:

-- Make widgets reactive
e1 <- lineEditText l1
e2 <- lineEditText l2
btn <- buttonClick tb

-- Connection rules
e1 =:= (involution reverse <$$> e2)
e1 <:= (btn `governingR` e2 :: ReactiveFieldRead IO String)

This makes:

  • e1 and e2 always represent the same text, reversed from one another. Typing in top box Typing in bottom box

  • Whenever the button is depressed, the text in e2 is copied (literally) onto e1. (Consequently, e2 also changes as per rule #1.) We say that the button click is '''governing''' the line edit text, because the button determines when changes to the text are propagated. Button click Text transfers up, reverses down

The full code of the example can be found at:

https://github.com/keera-studios/hails-reactive-qt/blob/master/examples/Example.hs#L54

which shows how to connect widgets a-la Keera Hails. See also: