vendredi 28 avril 2017

why I get an "use of delete function" from a class thats inherits from QAbstractListModel

I am trying to implement a ListView, so far I implement a class named PacientModel that inherits of QAbstractListModel.

#ifndef PACIENTMODEL_H
#define PACIENTMODEL_H

#include <QAbstractListModel>

class PacientModel : public QAbstractListModel {
    Q_OBJECT

public:
    enum PacientRole {
        CIRole,
        NameRole,
        LastNameRole
    };
    Q_ENUM(PacientRole)

    PacientModel(QObject * parent = nullptr);

    int rowCount(const QModelIndex & = QModelIndex()) const;
    QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const;
    QHash<int, QByteArray> roleNames() const;

    Q_INVOKABLE QVariantMap get(int row) const;
    Q_INVOKABLE void append (const QString &CI, const QString &name, const QString &lastName);
    Q_INVOKABLE void set (int row, const QString & CI, const QString &name, const QString &lastName);
    Q_INVOKABLE void remove (int row);

private:
    struct Pacient {
        QString CI;
        QString name;
        QString lastName;
    };

    QList<Pacient> m_pacients; };

#endif // PACIENTMODEL_H

I also have the implementation of the ListView but when I compile the code I got this error.

C:\Qt\Qt5.8.0\5.8\android_armv7\include\QtCore\qmetatype.h:765: error: use of deleted function 'PacientModel::PacientModel(const PacientModel&)' return new (where) T(*static_cast(t));

How can I resolve this, any help will be very usefull. Thanks in advance

Aucun commentaire:

Enregistrer un commentaire