vendredi 25 décembre 2015

Cannot add my class in the QList

I have my custom class that delivered from QObject:

class Client : public QObject
{
    Q_OBJECT
    friend class Server;
public:
    Client(QTcpSocket *socket, QObject *parent = 0);
private:
    QTcpSocket *mSocket;
};

And try to add it in the my list (QList)

auto socket = mServer->nextPendingConnection();
Client client(socket);
mClients.append(client);

It outputs next:

/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:521: required from 'void QList::append(const T&) [with T = Client]'
...
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:372: error: use of deleted function 'Client::Client(const Client&)' if (QTypeInfo::isLarge || QTypeInfo::isStatic) n->v = new T(t);

How I can add my object in the list correctly?

Aucun commentaire:

Enregistrer un commentaire