{"id":16608443,"url":"https://github.com/oclero/qtutils","last_synced_at":"2025-10-29T16:32:24.530Z","repository":{"id":75835921,"uuid":"455274476","full_name":"oclero/qtutils","owner":"oclero","description":"A set of tools for Qt5.","archived":false,"fork":false,"pushed_at":"2024-02-18T13:38:32.000Z","size":45,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-02-18T14:34:27.702Z","etag":null,"topics":["cmake","cpp","qt5"],"latest_commit_sha":null,"homepage":"","language":"C++","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/oclero.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-02-03T18:06:16.000Z","updated_at":"2024-02-17T18:07:49.000Z","dependencies_parsed_at":"2024-02-21T13:15:10.699Z","dependency_job_id":null,"html_url":"https://github.com/oclero/qtutils","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oclero%2Fqtutils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oclero%2Fqtutils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oclero%2Fqtutils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oclero%2Fqtutils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oclero","download_url":"https://codeload.github.com/oclero/qtutils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219857423,"owners_count":16556062,"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":["cmake","cpp","qt5"],"created_at":"2024-10-12T01:26:14.488Z","updated_at":"2025-10-29T16:32:24.138Z","avatar_url":"https://github.com/oclero.png","language":"C++","readme":"\u003cdiv align=\"center\"\u003e\n\t\u003cimg height=\"50\" src=\"logo.svg\"\u003e\n\u003c/div\u003e\n\n# QtUtils\n\n[![License: MIT](https://img.shields.io/badge/license-MIT-green)](https://mit-license.org/)\n[![CMake version](https://img.shields.io/badge/CMake-3.21+-064F8C?logo=cmake)](https://www.cmake.org)\n[![C++ version](https://img.shields.io/badge/C++-17-00599C?logo=++)](https://en.cppreference.com)\n[![Qt version](https://img.shields.io/badge/Qt-6.0.0+-41CD52?logo=qt)](https://www.qt.io)\n\n**QtUtils** is a set of basic utilities that I consider should be part of Qt API. It contains many helpers that improve the Qt experience, from dealing with `enum` to usage of pointers.\n\n---\n\n### Table of Contents\n\n- [Requirements](#requirements)\n- [Usage](#usage)\n- [Content](#content)\n- [Author](#author)\n- [License](#license)\n\n---\n\n## Requirements\n\n- Platform: Windows, MacOS, Linux.\n- [CMake 3.21+](https://cmake.org/download/)\n- [Qt 6.0.0+](https://www.qt.io/download-qt-installer)\n\n## Usage\n\n1. Add the library as a dependency with CMake FetchContent.\n\n   ```cmake\n   include(FetchContent)\n   FetchContent_Declare(QtUtils\n    GIT_REPOSITORY \"https://github.com/oclero/qtutils.git\"\n   )\n   FetchContent_MakeAvailable(QtUtils)\n   ```\n\n2. Link with the library in CMake.\n\n   ```cmake\n   target_link_libraries(your_project oclero::QtUtils)\n   ```\n\n3. Include headers in your C++ file.\n\n   ```c++\n   #include \u003coclero/QtConnectionUtils.hpp\u003e\n   ```\n\n## Content\n\n### QtConnectionUtils\n\n#### Single-shot Connection\n\nThis connection handling will be called only once.\n\n```cpp\noclero::singleShotConnect(this, \u0026SomeClass::someSignalTriggered, []() {\n  // Do stuff.\n});\n```\n\n### QtScopedConnection\n\n- This connection will be closed when it is destroyed, i.e. when the scope it belongs ends. It's a RAII `QMetaObject::Connection`.\n\n  ```cpp\n  oclero::QtScopedConnection scopedConnection = QObject::connect(this, \u0026SomeClass::someSignalTriggered, []() {\n    // Do stuff.\n  });\n  ```\n\n- This `QMetaObject::Connection` container will close its content RAII-style.\n\n  ```cpp\n  oclero::QtScopedConnections scopedConnections;\n  scopedConnections.add(QObject::connect(this, \u0026SomeClass::someSignalTriggered, []() {\n    // Do stuff.\n  }));\n  ```\n\n### QtEnumUtils\n\n- Converts `enum` to `QString` and vice-versa. Checks if the value is valid.\n\n  ```cpp\n  auto str = oclero::enumToString(SomeEnum::SomeValue);\n  auto value = oclero::enumFromString\u003cSomeEnum\u003e(\"SomeValue\");\n  ```\n\n- Converts `enum` to `int` and checks if the value is valid.\n\n  ```cpp\n  auto value = oclero::enumFromInt(3);\n  ```\n\n### QtEventFilterUtils\n\nTired of writing a new class just to hook on an event? Now you can just write this:\n\n```cpp\noclero::EventFilter\u003cQEvent::MouseButtonPress\u003e::install(watchedObject, [](QMouseEvent* e) {\n  // Do stuff.\n  // Return 'true' to block the event propagation, 'false' otherwise.\n  return false;\n});\n```\n\nAll corresponding `QEvent`-derived classes have been mapped to their corresponding `QEvent::Type`, so you don't even have to cast the `QEvent` or worry about its type.\n\n### QtPointerUtils\n\n- A unique pointer that will call `QObject::deleteLater` instead of `delete` when its scope ends.\n\n  ```cpp\n  oclero::QtDeleteLaterScopedPointer\u003cQObject\u003e scopedPointer(rawPointer);\n  ```\n\n### QtSettingsUtils\n\nUtilities to make saving and retrieving values with `QSettings` more convenient.\n\n```cpp\nQSettings settings;\nauto value = oclero::loadSetting\u003cint\u003e(settings, \"key\", 3 /* default value */);\noclero::saveSetting(settings, \"key\", 3);\noclero::clearSetting(settings, \"key\");\n```\n\n## Author\n\n**Olivier Cléro** | [email](mailto:oclero@pm.me) | [website](https://www.olivierclero.com) | [github](https://www.github.com/oclero) | [gitlab](https://www.gitlab.com/oclero)\n\nThanks to Thomas Donel for his help.\n\n## License\n\n**QtUtils** is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foclero%2Fqtutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foclero%2Fqtutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foclero%2Fqtutils/lists"}