{"id":22190822,"url":"https://github.com/fairybow/stylist","last_synced_at":"2026-05-04T02:38:55.807Z","repository":{"id":265989981,"uuid":"896974963","full_name":"fairybow/Stylist","owner":"fairybow","description":"Stylist is a small, in-progress Qt C++ library adding an in-app system for live-styling QWidgets en masse.","archived":false,"fork":false,"pushed_at":"2025-03-08T16:42:26.000Z","size":9773,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T17:28:39.859Z","etag":null,"topics":["cpp","cpp20","qss","qt","qt6","stylesheets"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fairybow.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":"2024-12-01T18:57:00.000Z","updated_at":"2025-03-08T16:42:29.000Z","dependencies_parsed_at":"2025-02-22T17:37:56.985Z","dependency_job_id":null,"html_url":"https://github.com/fairybow/Stylist","commit_stats":null,"previous_names":["fairybow/stylist"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fairybow%2FStylist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fairybow%2FStylist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fairybow%2FStylist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fairybow%2FStylist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fairybow","download_url":"https://codeload.github.com/fairybow/Stylist/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245351757,"owners_count":20601087,"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","cpp20","qss","qt","qt6","stylesheets"],"created_at":"2024-12-02T12:12:46.481Z","updated_at":"2026-05-04T02:38:55.801Z","avatar_url":"https://github.com/fairybow.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stylist\n\nStylist is a small, in-progress Qt C++ library adding an in-app system for live-styling QWidgets en masse. It uses JSON-formatted themes compiled against template QSS sheets (variable replacement) and mass-applies the resulting QSS to user-defined widget type-groups.\n\nA program using Stylist can give users a way to choose and customize themes without using QSS (on the user-side).\n\nStylist is being developed as a component of [Fernanda](https://github.com/fairybow/Fernanda).\n\n\u003ckbd\u003e\n    \u003cimg src=\"demo/early-demo.gif\" alt=\"\"/\u003e\n\u003c/kbd\u003e\n\n## Usage\n\n### Note\n\nStylist API functions follow this general format:\n\n```cpp\nm_stylist-\u003esetProperty\u003cQWidgetT\u003e(\"value\");\nauto value = m_stylist-\u003eproperty\u003cQWidgetT\u003e();\n\n// If group was defined with the optional role parameter, it must be included:\nm_stylist-\u003esetProperty\u003cQWidgetT\u003e(\"value\", 1);\nauto value = m_stylist-\u003eproperty\u003cQWidgetT\u003e(1);\n\n// Or:\n// m_stylist-\u003esetProperty(typeid(QWidgetT), \"value\");\n// auto value = m_stylist-\u003eproperty(typeid(QWidgetT));\n```\n\nThe type of widget is specified with `typeid(T)` or as a template parameter. The optional `role` parameter allows the creation of separate groups with the same type. So, a type-group is defined as `{ T, role = 0 }`.\n\n### Include\n\n```cpp\n#include \"Stylist/Stylist.h\"\n\n// To use the controller widget from Stylist's dialog (see below)\n// #include \"Stylist/Controller.h\"\n```\n\n### Create Stylist and set it up to handle one or more types of QWidget\n\n```cpp\nStylist* m_stylist = new Stylist(this);\n```\n\n(Stylist is a subclass of `QObject`.)\n\nDefine a type-group or -groups:\n\n```cpp\nm_stylist-\u003esetName\u003cQMainWindow\u003e(\"Windows\");\nm_stylist-\u003esetThemesTemplate\u003cQMainWindow\u003e(\":/qrc/Window.stylist_template\");\nm_stylist-\u003esetThemesExtension\u003cQMainWindow\u003e(\".window_theme\");\nm_stylist-\u003esetBaseQss\u003cQMainWindow\u003e(\":/qrc/WindowBase.qss\");\n\n// Or:\n// m_stylist-\u003edefine\u003cQMainWindow\u003e(\n//     \"Windows\",\n//     \":/qrc/Window.stylist_template\",\n//     \".window_theme\",\n//     \":/qrc/WindowBase.qss\");\n```\n\nUse `Stylist::setUseTheme\u003cT\u003e(bool)` to toggle theme at runtime. When toggled off, only base QSS (or no QSS) will show.\n\n### Add directories containing themes files with the pre-specified extension(s)\n\n\u003e [!IMPORTANT] \n\u003e Unique extensions are needed for each kind of theme.\n\n```cpp\nm_stylist-\u003eaddThemesDirectory(\":/qrc2/\");\nm_stylist-\u003esetCurrentTheme\u003cQMainWindow\u003e(\":/qrc2/Dark.window_theme\");\n```\n\n### Associate widgets with Stylist\n\n\"Yoking\" (like with oxen) associates widgets with their pre-defined type-group or creates the group if it doesn't already exist.\n\n```cpp\nQTextEdit* MyMainWindow::newQTextEdit()\n{\n    auto text_edit = new QTextEdit(this);\n    m_stylist-\u003eyoke(text_edit);\n\n    // Setup text edit...\n\n    return text_edit;\n}\n```\n\n### Controlling Stylist\n\n```cpp\n// Open a dialog through Stylist:\nm_stylist-\u003eshowDialog();\n\n// Or use Stylist::Controller to integrate the controls into something else:\n// auto controller = new Stylist::Controller(m_stylist, this);\n// window-\u003esetCentralWidget(controller);\n```\n\nA `Stylist::Controller` takes a required `Stylist` pointer on creation (and the usual optional `QWidget` parent pointer).\n\n### Demo\n\nSee the [demo project](demo) for a more involved example.\n\n## Adding Stylist to a project\n\nCopy the `lib` and `include` folders to the target repo, and include `lib\\Stylist.lib` in the compilation. Ensure `Stylist.dll` (in the `bin` folder) is also copied to the directory of the output `.exe`. Access via the `include\\Stylist\\Stylist.h` header.\n\n## Limitations\n\n### Qt style sheets\n\nThis tool is limited, of course, by any limitations of Qt Stylesheets. Of particular note, QWidgets will inherit style from their parents. For example, setting the following base QSS on a `QMainWindow` will also remove the `QSizeGrip` from its child windows:\n\n```css\nQSizeGrip\n{\n    image: url(none);\n}\n```\n\n### Widget Trees and Cascading\n\nStylist groups are effectively **widget trees**, not just flat collections. Because QSS cascades from parent to child, yoking a top-level window applies that group's styling to all of its descendants automatically. You don't need to yoke each child widget.\n\nThis means different top-level windows can belong to different groups, each with distinct styling for their child widgets:\n\n```cpp\n// Window A and its children get \"Dark\" styling\nm_stylist-\u003eyoke(windowA);\nm_stylist-\u003esetCurrentTheme\u003cQMainWindow\u003e(\"Dark.window_theme\");\n\n// Window B and its children get \"Light\" styling (different group via role)\nm_stylist-\u003eyoke(windowB, 1);\nm_stylist-\u003esetCurrentTheme\u003cQMainWindow\u003e(\"Light.window_theme\", 1);\n```\n\nYou can also create groups for specific widget types independent of their parent windows:\n\n```cpp\nm_stylist-\u003edefine\u003cQTextEdit\u003e(\"Editors\", \":/Editor.stylist_template\", \".editor_theme\");\nm_stylist-\u003eyoke(someTextEdit);\n```\n\n**Caveat:** QSS cascading can cause conflicts. If a window group's QSS defines styles for `QTextEdit`, those rules may override styles from a separate `QTextEdit`-specific group, depending on selector specificity.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffairybow%2Fstylist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffairybow%2Fstylist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffairybow%2Fstylist/lists"}