title: how is assignment by reference done in Qt for QObjects?
body: <p>In Qt, when trying to assign a reference I am getting <code>use of deleted function</code> error:</p>
  
  <pre><code>/home/niko/QT_snippets/QML1/users.cpp:16: error: use of deleted function 'User::User(const User&amp;)'
       User user=users_map.value("email@domain.com");
                                                   ^
           ^
  /home/niko/QT_snippets/QML1/users.h:7: In file included from ../QML1/users.h:7:0,
  /home/niko/QT_snippets/QML1/users.cpp:1: from ../QML1/users.cpp:1:
  /home/niko/QT_snippets/QML1/user.h:6: 'User::User(const User&amp;)' is implicitly deleted because the default definition would be ill-formed:
   class User : public QObject
         ^
  /opt/Qt/5.7/gcc_64/include/QtCore/QObject:1: In file included from /opt/Qt/5.7/gcc_64/include/QtCore/QObject:1:0,
  /home/niko/QT_snippets/QML1/users.h:4: from ../QML1/users.h:4,
  /home/niko/QT_snippets/QML1/users.cpp:1: from ../QML1/users.cpp:1:
  </code></pre>
  
  <p>In C, I was always using pointers and I never had any problem, but as I see in C++ everybody uses references.</p>
  
  <p>How should I assign an object by reference in Qt? For example, in this line how should I make the <code>user</code> object be a reference to a value in <code>users_map</code> object?</p>
  
  <pre><code>User user=users_map.value("email@domain.com");
  </code></pre>
  
  <p>Or maybe the following?</p>
  
  <pre><code>User user=&amp;users_map.value("email@domain.com");
  </code></pre>
  
  <p>Because... the code above does not compile. I need to use it inside methods of <code>Users</code> class to access the data in <code>users_map</code> variable.</p>
  
  <p>The <code>Users</code> class is declared as:</p>
  
  <pre><code>class Users : public QAbstractItemModel
  {
      Q_OBJECT
      enum UserRoles {
          EmailRole = Qt::UserRole + 1,
          NameRole,
          PasswordRole
      };
  private:
      QMap&lt;QString,User&gt;         users_map;
  public:
      explicit Users(QAbstractItemModel *parent = 0);
      Q_INVOKABLE QModelIndex index(int row, int column,const QModelIndex &amp;parent = QModelIndex()) const;
      Q_INVOKABLE QModelIndex parent(const QModelIndex &amp;child) const;
      Q_INVOKABLE int rowCount(const QModelIndex &amp;parent = QModelIndex()) const;
      Q_INVOKABLE int columnCount(const QModelIndex &amp;parent = QModelIndex()) const;
      Q_INVOKABLE QVariant data(const QModelIndex &amp;index, int role = Qt::DisplayRole) const;
      QHash&lt;int, QByteArray&gt; roleNames() const;
  signals:
  
  public slots:
  };
  </code></pre>
  
  <p>The <code>User</code> class is declared like this:</p>
  
  <pre><code>class User : public QObject
  {
      Q_OBJECT
      Q_PROPERTY(QString email READ get_email WRITE set_email NOTIFY emailChanged);
      Q_PROPERTY(QString name READ get_name WRITE set_name NOTIFY nameChanged);
      Q_PROPERTY(QString password READ get_password WRITE set_password NOTIFY passwordChanged);
  private:
      QString             email;
      QString             name;
      QString             password;
  public:
      explicit User(QObject *parent = 0);
      QString get_email();
      void set_email(QString data);
      QString get_name();
      void set_name(QString data);
      QString get_password();
      void set_password(QString data);
  
  signals:
      void emailChanged();
      void nameChanged();
      void passwordChanged();
  
  public slots:
  };
  </code></pre>