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. QList: Append a custom class.

QList: Append a custom class.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 2.1k Views
  • 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.
  • B Offline
    B Offline
    brunjak
    wrote on last edited by
    #1

    Hi,
    I'm new in c++ and qt and I'm struggling with QList and copy-constructor. Compiling results in the following erros:

    error: undefined reference to `MachineSet::operator=(MachineSet const&)'

    within the header file

    class Production
        {
        public:
            Production()
            {
            }
            Production(const Production& production)
            {
                mMachineSet = production.mMachineSet;
            }
            Production &operator = (const Production &other);
    
            MachineSet mMachineSet;
            MaterialSet mMaterialSet;
            ToolSet mToolSet;
            CutterSet mCutterSet;
            GeometrySet mGeometrySet;
        };
    

    The definition of MachineSet is as follows:

    class MachineSet
    {
    public:
        MachineSet(const QString &fileName);
        MachineSet(const MachineSet& machineSet);   // Copy-Konstruktor
        MachineSet();
        MachineSet *operator = (const MachineSet &other);
        ~MachineSet();
    
        enum class MYERROR
        {
            noError,
            couldNotOpenFile,
            dataListIsEmpty,
            xmlStreamReaderError,
            qFileError
        };
    
        class Machine
        {
        public:
           Machine()
           {
               mCompany = "";
               mProductFamiliy = "";
               mProductName = "";
               mProductShortDescription = "";
               mProductDetailedDescription = "";
               mIp4Address = "";
               mUsername = "";
               mPassword = "";
               mLocation = "";
               mMaxWidth = 0.0;
               mMaxLength = 0.0;
               mMaxHight = 0.0;
           }
           QString mCompany;
           QString mProductFamiliy;
           QString mProductName;
           QString mProductShortDescription;
           QString mProductDetailedDescription;
           QString mIp4Address;
           QString mUsername;
           QString mPassword;
           QString mLocation;
           QString mFirstName;
           QString mLastName;
           QString mStreet;
           QString mHouseNumber;
           QString mZipCode;
           QString mCity;
           double mMaxWidth;
           double mMaxLength;
           double mMaxHight;
    
           Machine(const Machine& machine)       // copy-constructor
           {
               mCompany = machine.mCompany;
               mProductFamiliy = machine.mProductFamiliy;
               mProductName = machine.mProductName;
               mProductShortDescription = machine.mProductShortDescription;
               mProductDetailedDescription = machine.mProductDetailedDescription;
               mIp4Address = machine.mIp4Address;
               mUsername = machine.mUsername;
               mPassword = machine.mPassword;
               mLocation = machine.mLocation;
               mFirstName = machine.mFirstName;
               mLastName = machine.mLastName;
               mStreet = machine.mStreet;
               mHouseNumber = machine.mHouseNumber;
               mZipCode = machine.mZipCode;
               mCity = machine.mCity;
               mMaxWidth = machine.mMaxWidth;
               mMaxLength = machine.mMaxLength;
               mMaxHight = machine.mMaxHight;
           }
    
           Machine *operator = (const Machine &other);
        };
    
        QList<Machine> mMachineSetList;
        QFile *p_mXmlFile;
    
        QXmlStreamReader mXmlStreamRead;
        QXmlStreamWriter mXmlStreamWrite;
    
        MYERROR readSetFromXmlFile();
        MYERROR readMachineFromXmlFile(Machine *p_machine);
    
        MYERROR writeSetToXmlFile();
        MYERROR writeMachineToXmlFile(Machine *p_machine);
    
    private:
        QString mFilename;
    
    };
    

    Any idea? Thank you
    Jakob

    1 Reply Last reply
    0
    • B Offline
      B Offline
      brunjak
      wrote on last edited by
      #3

      Thank you for your help. The problem was here:

      MachineSet &operator = (const MachineSet &other);

      changing to

      MachineSet operator = (const MachineSet &other);

      works.

      Thank you

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #2

        Production &operator = (const Production &other);

        I suspect the issue with the signature. Try changing like the following.

        Production operator = (const Production &other)

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        5
        • B Offline
          B Offline
          brunjak
          wrote on last edited by
          #3

          Thank you for your help. The problem was here:

          MachineSet &operator = (const MachineSet &other);

          changing to

          MachineSet operator = (const MachineSet &other);

          works.

          Thank you

          1 Reply Last reply
          0

          • Login

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