Important: Please read the Qt Code of Conduct -

can't add an object to a QList

  • Hi all -

    So, what am I doing wrong here? I'm getting a build error:

    error: 'QUdpSocket::QUdpSocket(const QUdpSocket&)' is private

    class UdpSocket : public QObject
        QList<QUdpSocket> m_interfaceSockets;
    void UdpSocket::pollNetworkInterfaces()
        QUdpSocket *sock = new QUdpSocket;

  • Moderators

    You're trying to copy the object into the list. QObjects are not copyable.
    To fix this you can change the list to be a list of pointers instead.

Log in to reply