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
    Q_DISABLE_COPY(QUdpSocket)

    class UdpSocket : public QObject
    {
        Q_OBJECT
    
    private:
        QList<QUdpSocket> m_interfaceSockets;
    }
    void UdpSocket::pollNetworkInterfaces()
    {
        QUdpSocket *sock = new QUdpSocket;
        m_interfaceSockets.append(*sock);
    ..
    

  • 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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.