title: Singleton with QObject inheritance - Qt
body: <p>Is it possible to create singleton class with QObject inheritance? I have an compilation error afer adding QObject inheritance. Maybe problem is in static singleton creation (should be dynamic)? Here is my approach </p>
  
  <p>Header </p>
  
  <pre class="lang-cpp prettyprint-override"><code>#ifndef BLUETOOTHMANAGER_H
  #define BLUETOOTHMANAGER_H
  
  #include &lt;QObject&gt;
  
  class BluetoothManager : public QObject
  {
      Q_OBJECT
  public:
      virtual ~BluetoothManager() {}
  
      /// Static getter
      static BluetoothManager &amp; GetInstance()
      {
          return instance;
      }
  
  private:
      /// static Bluetooth manager instance
      static BluetoothManager instance;
  
      explicit BluetoothManager(QObject * parent);
  };
  
  #endif // BLUETOOTHMANAGER_H
  </code></pre>
  
  <p>And cpp file</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include "BluetoothManager.h"
  
  /// singleton creation
  BluetoothManager BluetoothManager::instance = BluetoothManager(static_cast&lt;QObject*&gt;(nullptr));
  
  BluetoothManager::BluetoothManager(QObject * parent)
      : QObject(parent)
  {
  
  }
  </code></pre>
  
  <p>During compilation i have an error </p>
  
  <pre><code>../QtHealthApp/network/bluetooth/BluetoothManager.cpp:4:94: error: use of deleted function ‘BluetoothManager::BluetoothManager(const BluetoothManager&amp;)’  BluetoothManager BluetoothManager::instance = BluetoothManager(static_cast&lt;QObject*&gt;(nullptr));
                                                                                                ^ In file included from /opt/Qt5.12.LTS/5.12.6/gcc_64/include/QtCore/qnamespace.h:43:0,
                   from /opt/Qt5.12.LTS/5.12.6/gcc_64/include/QtCore/qobjectdefs.h:48,
                   from /opt/Qt5.12.LTS/5.12.6/gcc_64/include/QtCore/qobject.h:46,
                   from /opt/Qt5.12.LTS/5.12.6/gcc_64/include/QtCore/QObject:1,
                   from ../QtHealthApp/network/bluetooth/BluetoothManager.h:4,
                   from ../QtHealthApp/network/bluetooth/BluetoothManager.cpp:1: ../QtHealthApp/network/bluetooth/BluetoothManager.h:33:20: note: declared here
       Q_DISABLE_COPY(BluetoothManager)
                      ^ /opt/Qt5.12.LTS/5.12.6/gcc_64/include/QtCore/qglobal.h:372:5: note: in definition of macro ‘Q_DISABLE_COPY’
       Class(const Class &amp;) Q_DECL_EQ_DELETE;\
       ^
  </code></pre>