Implementing a declarative GUI language

I recently started work on a GUI project using some form of declarative language. I mean, I need to describe the hierarchy of objects without specifying the type of GUI widgets that will be used to “show” this hierarchy. For example, for some existing H hierarchy , using JSON notation (or something like that):

H = 
{
    "title" : "Label_1"
    "children" : 
    [
        {
            "title" : "Label_2"
            "children": 
            [
                {
                    "title": "Field_A"
                    "type": "Integer"
                    "value": 10
                },

                {
                    "title": "Field_B"
                    "type": "String"
                    "value": "YES"
                }
            ]
         }
    ]
}

Someone can create a simple window that will be shown to the user by clicking the button labeled "Label_1". The window can then be entitled "Label_2" and have two fields labeled "Field_A" and "Field_B", taking integer and logical values, respectively.

Someone else might put this hierarchy in a list of trees, for example

--------------------------------------------------------
>Label_1                |
    >Label_2            |
        >Field_A        |   10
        >Field_B        |   YES

: , - - ? JSON? , (- / ). , . , , .

.

+3
3

JSON . XML - , Microsoft XAML ( XML) , W3C ( ) ( XML). , .

+5

, , QML

Qt GUI , JSON.

, , Open Source, GUI. , .

+4

I am just testing QML for a real user interface environment in a Qt-based C ++ project. And I think it is very powerful as a declarative language, so if you already know some of the basics of Qt, you can use it.

You can create modern, professional, and attractive user interfaces very quickly. And you can also easily connect the declarative language to your C ++ code and vice versa.

+1
source

Source: https://habr.com/ru/post/1734695/


All Articles