QtUtils
Presentation
QtUtils is a set of tools to make using Qt5 more convenient.
I was tired of implementing again and again the same utilities company after company, so I decided to make an open-source library with these commonly used tools, so everyone can enjoy them.
Library Content
-
singleShotConnect: Allows to create a single-shotQMetaObject::Connection.1 2 3oclero::singleShotConnect(this, &SomeClass::someSignalTriggered, []() { // Do stuff. }); -
QtScopedConnection: RAIIQMetaObject::Connectionthat will disconnect when destroyed.1 2 3oclero::QtScopedConnection scopedConnection = QObject::connect(this, &SomeClass::someSignalTriggered, []() { // Do stuff. }); -
QtEnumUtils: Utilities to convert enums toQStringorintand vice-versa.1 2auto str = oclero::enumToString(SomeEnum::SomeValue); auto value = oclero::enumFromString<SomeEnum>("SomeValue"); -
QtEventFilterUtils: Utilities to quickly register to an event without the burden to create aclass. All correspondingQEvent-derived classes have been mapped to their correspondingQEvent::Type, so you don’t even have to cast theQEventor worry about its type.1 2 3 4oclero::EventFilter<QEvent::MouseButtonPress>::install(watchedObject, [](QMouseEvent* e) { // Do stuff, then return 'true' to block the event propagation, 'false' otherwise. return false; }); -
QtDeleteLaterScopedPointer: A pointer manager likestd::unique_ptrorQScopedPointer, but callsdeleteLater()instead ofdelete.1oclero::QtDeleteLaterScopedPointer<QObject> scopedPointer(rawPointer); -
QtSettingsUtils: Utilities to save and load strongly typed values fromQSettings.1 2 3 4QSettings settings; auto value = oclero::loadSetting<int>(settings, "key", 3 /* default value */); oclero::saveSetting(settings, "key", 3); oclero::clearSetting(settings, "key");
Information
- Repository: https://github.com/oclero/qtutils
- License: MIT
