{"id":24334360,"url":"https://github.com/hubenchang0515/qttheme","last_synced_at":"2025-04-07T07:01:40.857Z","repository":{"id":169580177,"uuid":"644930139","full_name":"hubenchang0515/QtTheme","owner":"hubenchang0515","description":"Qt theme in pure qss - 纯 QSS 的 Qt 主题","archived":false,"fork":false,"pushed_at":"2025-03-15T18:50:30.000Z","size":180994,"stargazers_count":79,"open_issues_count":0,"forks_count":14,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T06:01:01.819Z","etag":null,"topics":["cpp","pyqt5","pyqt6","pyside2","pyside6","python","qss","qt5","qt6","wasm"],"latest_commit_sha":null,"homepage":"https://xplanc.org/QtTheme/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hubenchang0515.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":"2023-05-24T14:46:28.000Z","updated_at":"2025-03-31T01:11:40.000Z","dependencies_parsed_at":"2025-03-31T06:10:46.488Z","dependency_job_id":null,"html_url":"https://github.com/hubenchang0515/QtTheme","commit_stats":null,"previous_names":["hubenchang0515/qttheme"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hubenchang0515%2FQtTheme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hubenchang0515%2FQtTheme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hubenchang0515%2FQtTheme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hubenchang0515%2FQtTheme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hubenchang0515","download_url":"https://codeload.github.com/hubenchang0515/QtTheme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247608150,"owners_count":20965952,"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","pyqt5","pyqt6","pyside2","pyside6","python","qss","qt5","qt6","wasm"],"created_at":"2025-01-18T04:15:47.839Z","updated_at":"2025-04-07T07:01:35.839Z","avatar_url":"https://github.com/hubenchang0515.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Qt Theme\n\n![CMake Build on Qt5](https://github.com/hubenchang0515/QtTheme/actions/workflows/cmake-qt5.yml/badge.svg)\n![CMake Build on Qt5](https://github.com/hubenchang0515/QtTheme/actions/workflows/cmake-qt6.yml/badge.svg)\n![License](https://img.shields.io/github/license/hubenchang0515/QtTheme?label=License\n)\n![License: MIT](https://img.shields.io/badge/License-MIT-lightgreen.svg)\n[![PyPI](https://img.shields.io/pypi/v/QtTheme?label=pypi%20package)](https://pypi.org/project/QtTheme/)\n\nQt theme in pure qss - 纯 qss 的 Qt 主题\n\n[Preview and Export Resource Package Online - 在线预览和导出资源包](https://hubenchang0515.github.io/moe-tools/#/qt-theme)\n\n## Preview - 预览\n\n![dark](./doc/image/dark.png)\n\n![light](./doc/image/light.png)\n\n## Usage - 使用说明\n\n\u003e QtTheme is a pure QSS project, no language restrictions, use C++ description here.\n\n1. Export the resource package from [here](https://hubenchang0515.github.io/moe-tools/#/qt-theme), and add it to your project.\n\n2. Use `QMainWindow::setStyleSheet` to set the global style.\n    ```c++\n    QFile file(\":/QtTheme/theme/Flat/Dark/Blue/Pink.qss\");\n    file.open(QFile::ReadOnly);\n    setStyleSheet(file.readAll());\n    ```\n3. Use `QWdiget::setProperty` to set the color.\n    ```c++\n    auto button = new QPushButton(tr(\"Button\"));\n    button-\u003esetProperty(\"Color\", \"Primary\");\n    ```\n\n| Color        | Explain                                                                    |\n| :----------- | :------------------------------------------------------------------------- |\n| Primary      | The primary color selected when exporting                                  |\n| Secondary    | The secondary color selected when exporting                                |\n| Success      | The success color(![GREEN](https://placehold.co/16x16/4caf50/4caf50.png))  |\n| Warning      | The warning color(![ORANGE](https://placehold.co/16x16/ff9800/ff9800.png)) |\n| Danger       | The error color(![RED](https://placehold.co/16x16/f44336/f44336.png))      |\n\n--- \n\n\u003e QtTheme 是纯 QSS 的项目，不受语言限制，这里使用 C++ 描述。\n\n1. 在[这里](https://hubenchang0515.github.io/moe-tools/#/qt-theme)导出资源包，然后将其加入你的项目。\n\n2. 使用 `QMainWindow::setStyleSheet` 设置全局样式。\n    ```c++\n    QFile file(\":/QtTheme/theme/Flat/Dark/Blue/Pink.qss\");\n    file.open(QFile::ReadOnly);\n    setStyleSheet(file.readAll());\n    ```\n\n3. 使用 `QWdiget::setProperty` 设置颜色。\n    ```c++\n    auto button = new QPushButton(tr(\"Button\"));\n    button-\u003esetProperty(\"Color\", \"Primary\");\n    ```\n\n| 颜色          | 说明                                                         |\n| :----------- | :----------------------------------------------------------  |\n| Primary      | 导出时选择的主要颜色                                           |\n| Secondary    | 导出时选择的次要颜色                                           |\n| Success      | 成功色(![绿色](https://placehold.co/16x16/4caf50/4caf50.png)) |\n| Warning      | 警告色(![橙色](https://placehold.co/16x16/ff9800/ff9800.png)) |\n| Danger       | 危险色(![红色](https://placehold.co/16x16/f44336/f44336.png)) |\n\n## Notice - 注意事项\n\nCustomized `QWidget` subclasses must override `paintEvent`, otherwise the style will not take effect on this class:  \n\n自定义的 `QWidget` 子类，必须重载 `paintEvent`，否则样式不会再该类上生效:  \n\n\u003e https://doc.qt.io/qt-6/stylesheet-reference.html#qwidget-widget\n\n```cpp\nvoid CustomWidget::paintEvent(QPaintEvent *)\n{\n    QStyleOption opt;\n    opt.initFrom(this);\n    QPainter p(this);\n    style()-\u003edrawPrimitive(QStyle::PE_Widget, \u0026opt, \u0026p, this);\n}\n```\n\n\nStyle will not update itself automatically when the value of a property referenced from the style sheet changes, you must update it manually:  \n\n当样式表引用的属性值发生变化时，样式不会自动更新，必须手动更新:  \n\n\u003e https://wiki.qt.io/Dynamic_Properties_and_Stylesheets\n\n```cpp\n// property changes\nwidget-\u003esetProperty(\"Color\", \"Secondary\");\n\n// update style manually\nwidget-\u003estyle()-\u003eunpolish(widget);\nwidget-\u003estyle()-\u003epolish(widget);\n```\n\nQComboBox must set the view for the internal style to take effect:  \n\nQComboBox 必须设置 view, 内部的样式才能生效:  \n\n\u003e https://doc.qt.io/qt-6/stylesheet-reference.html#qcombobox-widget\n\n```cpp\ncomboBox-\u003esetView(new QListView);\n```\n\n## Python\n\n[![PyPI](https://img.shields.io/pypi/v/QtTheme?label=pypi%20package)](https://pypi.org/project/QtTheme/)\n\nInstall - 安装:  \n\n```bash\npip install QtTheme\n```\n\nUsage - 使用:  \n\nSee [here](https://pypi.org/project/QtTheme/) - 看[这里](https://pypi.org/project/QtTheme/)\n\n\u003e This method will include all resources of QtTheme. \n\u003e It is recommended to export the resource package from [here](https://hubenchang0515.github.io/QtTheme/), \n\u003e and add it to your project by RCC (`pyrcc5` or `pyside6-rcc`).\n\n\u003e 这种方式将会包含 QtTheme 的全部资源。\n\u003e 建议从 [这里](https://hubenchang0515.github.io/QtTheme/) 导出资源包，\n\u003e 然后通过 RCC (`pyrcc5` or `pyside6-rcc`) 将它加入你的项目。\n\n## Build - 构建\n\n**Dependencies - 依赖**  \n\n* Deb \u0026 Qt5: `qtbase5-dev`, `qttools5-dev`  \n* Deb \u0026 Qt6: `qt6-base-dev`, `qt6-tools-dev`  \n* Rpm \u0026 Qt5: `qt5-qtbase-devel`, `qt5-qttools-devel`  \n* Rpm \u0026 Qt6: `qt6-qtbase-devel`, `qt6-qttools-devel`  \n\n```bash\ngit clone git@github.com:hubenchang0515/QtTheme.git\ncd QtTheme\ngit submodule update --init\nmkdir build\ncd build\ncmake .. -DCMAKE_BUILD_TYPE=Release\ncmake --build . --config Release --parallel\n```\n\n## License\n\n![License](https://img.shields.io/github/license/hubenchang0515/QtTheme?label=License\n)\n![License: MIT](https://img.shields.io/badge/License-MIT-lightgreen.svg)\n\n* This Project - 这个项目: `AGPL-3.0-or-later` \n* Exported Resource - 导出的资源: `MIT`\n\n## Contributors\n\n![contributors](https://contrib.rocks/image?repo=hubenchang0515/QtTheme)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubenchang0515%2Fqttheme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhubenchang0515%2Fqttheme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubenchang0515%2Fqttheme/lists"}