OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
SignalBlockWrapper.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
11
12// Qt header
13#include <QtCore/qobject.h>
14
15namespace ot {
16
21 public:
24 SignalBlockWrapper(QObject* _object) : m_object(_object), m_initialState(false) {
25 if (m_object) {
26 m_initialState = m_object->signalsBlocked();
27 m_object->blockSignals(true);
28 }
29 }
30
34 if (m_object) {
35 m_object->blockSignals(m_initialState);
36 }
37 }
38 private:
39 QObject* m_object;
40 bool m_initialState;
41 };
42
43}
This file contains defines that may be used simplyfy class creation.
#define OT_DECL_NODEFAULT(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:22
#define OT_DECL_NOCOPY(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:14
#define OT_WIDGETS_API_EXPORT
Definition OTWidgetsAPIExport.h:12
The SignalBlockWrapper is a RAII wrapper for blocking signals of a given QObject.
Definition SignalBlockWrapper.h:18
~SignalBlockWrapper()
Destructor. The "blocked signals" state of the provided object will be set back to the initial value,...
Definition SignalBlockWrapper.h:33
SignalBlockWrapper(QObject *_object)
Constructor. The currently set "block signals" state of the given object will be stored and the signa...
Definition SignalBlockWrapper.h:24
Definition Connector.h:8