Skip to content

race-engineering-center/QTonks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QTonks

Don't call me Nymphadora

A library built on top of Qt Widgets that allows you to dynamically build UIs for displaying and editing settings based on a JSON schema.

  1. Define your settings schema (see schema example below)
  2. QTonks will build a UI based on it
  3. Changing each setting from a UI will emit a signal with JSON containing all the settings
  4. You can load a JSON with current settings to update a UI as well

Supported widgets

  • Switch: a checkbox with a label that can be on or off
  • Enumeration: a group of options you can choose from
  • Integer: a field with an integer number and up/down buttons
  • Float: a field with a floating point number, up/down buttons, and a configurable step
  • Color: a control to pick a color using a dedicated color picker
  • Group: a container for any number of nested QTonks widgets

How it looks

QTonks look

Schema examples

Copy the following schema to the example application to get an idea how it works

{
    "schema":
    [
        {
            "name": "enableSomeStuff",
            "type": "switch",
            "label": "Enable some stuff"
        },
        {
            "name": "someOptionWithChoices",
            "type": "enumeration",
            "label": "Enumeration",
            "options": [
                "one", "two", "three"
            ],
            "labels": [
                "Fancy label one",
                "Very fancy label two",
                "Not so fancy label three"
            ],
            "defaultOption": "one"
        },
        {
            "name": "someIntegerValue",
            "label": "Number of something",
            "type": "integer",
            "min": 0,
            "max": 100,
            "default": 42
        },
        {
            "name": "someFloatValue",
            "label": "Some float value",
            "type": "float",
            "min": 0.0,
            "max": 1.0,
            "step": 0.01,
            "default": 0.5
        },
        {
            "name": "someGroup",
            "type": "group",
            "label": "Group of settings",
            "content": 
            [
                {
                    "name": "enableSomeGroupedStuff",
                    "type": "switch",
                    "label": "Enable some grouped stuff"
                },
                {
                    "name": "enableSomeOtherGroupedStuff",
                    "type": "switch",
                    "label": "Enable some other grouped stuff"
                },
                {
                    "name": "nestedGroup",
                    "type": "group",
                    "label": "Nested group of settings",
                    "content": 
                    [
                        {
                            "name": "nestedSwitch",
                            "type": "switch",
                            "label": "Wow!"
                        },
                        {
                            "name": "anotherDoubleValue",
                            "type": "float",
                            "label": "Some other float value",
                            "min": 5,
                            "max": 10,
                            "step": 0.1,
                            "default": 7
                        }
                    ]
                }
            ]
        },
        {
            "name": "colorPicker",
            "type": "color",
            "label": "Pick your favorite color",
            "default": "#aa00ff"
        }
    ]
}

About

A library built on top of Qt Widgets that allows you to dynamically build UIs for displaying and editing settings based on a JSON schema

Resources

License

Stars

Watchers

Forks

Contributors