Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. can't add an object to a QList
Forum Updated to NodeBB v4.3 + New Features

can't add an object to a QList

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 288 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    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);
    ..
    
    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      7

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved