{"id":15044970,"url":"https://github.com/agateau/qpropgen","last_synced_at":"2025-10-24T16:32:03.344Z","repository":{"id":53130649,"uuid":"117155822","full_name":"agateau/qpropgen","owner":"agateau","description":"Generates QObject properties from a YAML file.","archived":false,"fork":false,"pushed_at":"2022-12-28T21:41:51.000Z","size":52,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-31T03:27:49.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agateau.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-11T21:29:30.000Z","updated_at":"2023-08-12T21:44:20.000Z","dependencies_parsed_at":"2023-01-31T07:31:18.206Z","dependency_job_id":null,"html_url":"https://github.com/agateau/qpropgen","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateau%2Fqpropgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateau%2Fqpropgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateau%2Fqpropgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateau%2Fqpropgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agateau","download_url":"https://codeload.github.com/agateau/qpropgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238008507,"owners_count":19401263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T20:51:17.815Z","updated_at":"2025-10-24T16:32:02.949Z","avatar_url":"https://github.com/agateau.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/agateau/qpropgen.svg?branch=master)](https://travis-ci.org/agateau/qpropgen)\n\n# qpropgen\n\nA tool to generate QML-friendly QObject-based C++ classes from class definition\nfiles.\n\nInstall it with:\n\n    pip install qpropgen\n\n## Quick Intro\n\nDeclaring properties in a QObject class requires writing a lot of boilerplate\ncode. qpropgen goal is to write this boilerplate for you.\n\nSuppose we want to create a `Person` class, with `firstName`, `lastName` and\n`birthDate` properties.\n\nFirst we create a class definition file named `person.yaml` with the following\ncontent:\n\n```yaml\nclass: Person\nproperties:\n- name: firstName\n  type: QString\n- name: lastName\n  type: QString\n- name: birthDate\n  type: QDateTime\n```\n\nNext, we generate its header and implementation with `qpropgen person.yaml`.\nThis produces two files: `person.h` and `person.cpp` (The filenames are based\non the filename of the class definition).\n\nNote: in practice, you probably want to inherit from the generated classes to\nimplement other aspects of the class to create and/or to override getters and\nsetters.\n\n## Syntax of class definition files\n\nA class definition file **must** contain the following fields:\n\n- `class`: the name of the class to generate.\n\n- `properties`: the list of its properties (see below).\n\nIt **may** also contain the following fields:\n\n- `includes`: a list of files to include in the header.\n\n- `baseClass`: name of the class to inherit from. Defaults to `QObject`.\n\n- `defaults`: default values for some property attributes (see below).\n\n### The `properties` field\n\n`properties` is an array of property definitions.\n\nA property definition **must** contain the following fields:\n\n- `name`\n- `type` (can be set in the `defaults` field)\n\nIt **may** contain the following fields:\n\n- `access`: Can be `private` or `protected`. Defines the access modifier for\n  the generated member variables. Defaults to `private`.\n\n- `mutability`: One of `constant`, `readonly`, `readwrite`. Defaults to\n  `readwrite`.\n\n- `argType`: The type of the setter argument. If not set qpropgen uses const\n  references for types which are not pointers and not known scalars (int, bool,\n  qreal).\n\n- `varName`: Name of the variable backing the property. Defaults to `m\u003cName\u003e`,\n  so the variable of the `foo` property will be `mFoo`.\n\n- `setterName`: Name of the setter. Defaults to `set\u003cName\u003e`, so the setter of\n  the `foo` property will be `setFoo`.\n\n- `impl`: One of `plain` (getter and setter), `virtual` (virtual getter and\n  setter) or `pure` (virtual pure getter and setter). Defaults to `plain`.\n\n- `value`: The default value of the property.\n\n### The `defaults` field\n\nAdding a field to the `defaults` object lets you define default values for all\nproperties.\n\nFor example you can define that all properties are of type `qreal` by default\nwith:\n\n```yaml\ndefaults:\n  type: qreal\n```\n\nOf course fields which require a unique value, like `name`, should not have a\ndefault.\n\n## Build system integration\n\nThe `cmake/qpropgen.cmake` can be included in your project to integrate\nqpropgen. It takes care of finding the `qpropgen` executable and provides a\n`qpropgen()` CMake function.\n\nThis CMake function lets you define .yaml files to process. For example:\n\n\n```cmake\nset(prj_SRCS main.cpp)\nqpropgen(prj_QPROPGEN foo.yaml bar.yaml)\nadd_executable(prj ${prj_SRCS} ${prj_QPROPGEN})\n```\n\n## Examples\n\nThe `examples/` directory contains examples of the various settings. The\nproduced executable does nothing, but you can look in the build directory at\nthe .h and .cpp files produced by qpropgen during the build.\n\n## Tests\n\nThe `./tests.sh` script runs the unit tests and builds the examples.\n\n## Trivia\n\nI started this project when I was working on the [SFXR-Qt][] sound generator (a\nQtQuick port of [SFXR][]), and was finding it too tedious to declare all the\nproperties necessary to represent sounds :)\n\n[SFXR-Qt]: https://github.com/agateau/sfxr-qt\n[SFXR]: http://www.drpetter.se/project_sfxr.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagateau%2Fqpropgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagateau%2Fqpropgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagateau%2Fqpropgen/lists"}