{"id":16910985,"url":"https://github.com/yuja/qmluic","last_synced_at":"2025-03-22T10:31:52.120Z","repository":{"id":36953380,"uuid":"486213660","full_name":"yuja/qmluic","owner":"yuja","description":"QML -\u003e QtWidgets UI/C++ transpiler","archived":false,"fork":false,"pushed_at":"2025-03-20T09:45:21.000Z","size":1776,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-20T10:35:13.181Z","etag":null,"topics":["cpp","gui","qml","qt","qtwidgets"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuja.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-27T13:55:00.000Z","updated_at":"2025-03-20T09:45:24.000Z","dependencies_parsed_at":"2024-01-11T14:29:54.465Z","dependency_job_id":"1a059db7-ff72-401e-8f47-f16a6d425593","html_url":"https://github.com/yuja/qmluic","commit_stats":{"total_commits":1434,"total_committers":2,"mean_commits":717.0,"dds":"0.25453277545327757","last_synced_commit":"283cd61732e368c55b6e6e18eba75750e44415f1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuja%2Fqmluic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuja%2Fqmluic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuja%2Fqmluic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuja%2Fqmluic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuja","download_url":"https://codeload.github.com/yuja/qmluic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244943939,"owners_count":20536290,"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":["cpp","gui","qml","qt","qtwidgets"],"created_at":"2024-10-13T19:04:01.271Z","updated_at":"2025-03-22T10:31:51.535Z","avatar_url":"https://github.com/yuja.png","language":"Rust","readme":"qmluic - Write QtWidgets UI in QML\n==================================\n\n*A .qml-to-.ui transpiler.*\n\nWrite UI in QML:\n```qml\nimport qmluic.QtWidgets\n\nQDialog {\n    windowTitle: qsTr(\"Hello\")\n    QVBoxLayout {\n        QLabel { text: qsTr(\"Hello world!\") }\n    }\n}\n```\n\nRun live preview and polish the UI:\n```\n$ qmluic preview HelloDialog.qml\n```\n\nTranspile to `*.ui`/`ui_*.h`/`uisupport_*.h`:\n```\n$ qmluic generate-ui HelloDialog.qml\n$ uic hellodialog.ui -o ui_hellodialog.h\n```\n\nSee [examples/](examples/) directory for details.\n\nUsage\n-----\n\n`qmluic generate-ui` command translates `.qml` file to `.ui` XML file and\n`uisupport_*.h` C++ code. `.ui` can then be processed by Qt User Interface\nCompiler `uic` command. See [Dynamic Binding](#dynamic-binding) for\n`uisupport_*.h`.\n\nBy default, `qmluic generate-ui` loads type information from the\n`QT_INSTALL_LIBS/metatypes` directory. Use `--qmake` or `--foreign-types`\noption to load metatype.json files from the other directory or files.\n\n### CMake\n\nThere's a basic helper to integrate `qmluic generate-ui` in the build step.\nBy default, the output `.ui` and `.h` files are generated into the\n`CMAKE_CURRENT_BINARY_DIR`. This can be changed by the `OUTPUT_DIRECTORY`\noption.\n\nPlease make sure to not enable `CMAKE_AUTOUIC`, which conflicts with the .ui\ngeneration step.\n\n```cmake\nset(CMAKE_INCLUDE_CURRENT_DIR ON)\n# DO NOT ENABLE: set(CMAKE_AUTOUIC ON)\n\nfind_package(Qt6 REQUIRED COMPONENTS Widgets)\nfind_package(Qmluic REQUIRED)\n\n# Help Qt Creator find qmluic type stub\nset(QML_IMPORT_PATH ${QMLUIC_QML_IMPORT_PATH} CACHE STRING \"\" FORCE)\n\nadd_executable(myapp\n  main.cpp\n  ...\n)\n\nqmluic_target_qml_sources(myapp\n  MyDialog.qml\n  ...\n)\n```\n\nSee [examples/CMakeLists.txt](examples/CMakeLists.txt) for details.\n\n#### Optional CMake\n\nIf you want to optionally enable the qmluic integration, copy\n[cmake/QmluicShim.cmake](cmake/QmluicShim.cmake) to your project tree and\nload it if qmluic not found:\n\n```cmake\nfind_package(Qt6 REQUIRED COMPONENTS Widgets)\nfind_package(Qmluic QUIET)\nif(Qmluic_FOUND)\n  set(QML_IMPORT_PATH ${QMLUIC_QML_IMPORT_PATH} CACHE STRING \"\" FORCE)\nelse()\n  include(\"${CMAKE_SOURCE_DIR}/cmake/QmluicShim.cmake\")\nendif()\n\nqmluic_target_qml_sources(myapp\n  MyDialog.qml\n  ...\n  # Put the generated .ui in the source directory so they will be committed.\n  OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}\n)\n```\n\n### Code Completion\n\nYou can leverage the excellent Qt Creator's QML editor. You just need to add\n`share/qmluic/imports` to the `QML_IMPORT_PATH` so the creator can find our\ntype stubs.\n\nSee the following examples:\n\n* [examples/CMakeLists.txt](examples/CMakeLists.txt)\n* [examples/examples.qmlproject](examples/examples.qmlproject)\n\n### Live Preview\n\n`qmluic preview` command starts filesystem watcher, and updates the preview\nwindow to reflect the source QML file changes. It does not support multi-file\nQML sources yet.\n\n```\n$ qmluic preview HelloDialog.qml\n```\n\nThe previewer might not work on Windows because of the stdio use. Patches are\nwelcome.\n\n### Dynamic Binding\n\n(To turn off this feature, set `--no-dynamic-binding` or `NO_DYNAMIC_BINDING`\noption in CMake.)\n\n`qmluic generate-ui` generates a `uisupport_*.h` file in addition to `*.ui`,\nwhich sets up signal/slot connections for the dynamic binding expressions.\n\n```qml\nimport qmluic.QtWidgets\n\nQDialog {\n    id: root\n    QVBoxLayout {\n        QCheckBox { id: checkBox; checked: true }\n        QLabel { id: label; visible: checkBox.checked; text: qsTr(\"Checked\") }\n    }\n}\n```\n\nIn this example, `visible: checkBox.checked` is conceptually translated to the\nfollowing code:\n\n```c++\nvoid UiSupport::MainWindow::setup() {\n    connect(checkBox, \u0026QAbstractButton::toggled, root,\n            [this]() { label-\u003esetVisible(checkBox-\u003eisChecked()); });\n}\n```\n\n(The generated code would be more verbose since QML/JS expression is first\ntransformed to basic intermediate representation.)\n\n[A subset of QML/JS syntax is supported](docs/language.md).\n\nBuilding\n--------\n\nRequirements:\n\n- Rust\n- Cargo\n\nOptional requirements for previewer and type stubs:\n\n- CMake\n- Qt 5.15 or 6.2+\n\nIf you have all requirements installed, use Cargo and CMake to build/install\nthe binaries and data. There's a GNU Make wrapper to automate the build steps.\n\n```\n$ make release install\n```\n\nIf you just need to build the `qmluic` frontend, simply run\n`cargo build --release --workspace`.\n\nSee [Makefile](Makefile), [CMakeLists.txt](CMakeLists.txt), and\n[build.yml](.github/workflows/build.yml) for more details.\n\nDebugging\n---------\n\nDebug logging can be enabled by `QMLUIC_LOG` environment variable.\n\n```\n$ QMLUIC_LOG=trace cargo run -- generate-ui SettingsDialog.qml\n```\n\nhttps://docs.rs/env_logger/latest/env_logger/\n\nMajor TODOs\n-----------\n\n- [ ] Load type stubs from qmldir/plugins.qmltypes instead of metatypes.json\n- [ ] Better type resolution, namespace support\n- [ ] Live preview triggered by lsp\n- [ ] Live preview for multi-document file\n- [ ] Better support for static `QComboBox`/`QListWidget` items\n- [ ] Improve support for dynamic property bindings / signal callbacks\n  - [ ] `.toString()`\n  - [x] `\"\".isEmpty()`\n- [ ] Export helper functions from C++\n- [ ] User type and property (so C++ data model can be bound to UI)\n\nComparison to DeclarativeWidgets\n--------------------------------\n\n[DeclarativeWidgets](https://github.com/KDAB/DeclarativeWidgets) exports\nQtWidgets classes to the QML world. You can write widget application in a way\nyou would do for QtQuick applications. You can fully leverage property\nbindings, etc. The downside is the runtime dependency. And I guess it would\nbe a bit tedious to \"control\" a widget from C++ side.\n\n`qmluic` is merely a .ui file generator. You can't write expressive property\nbindings. You can (and need to) implement C++ counterpart for each QML UI.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuja%2Fqmluic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuja%2Fqmluic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuja%2Fqmluic/lists"}