Intruder
IntruderDec. 23, 2020, 3 p.m.

Почему вылетает ошибка: C:\DEVELOPMENT\Qt5.12.9\5.12.9\mingw73_64\include\QtCore\qvector.h:687: ошибка: cannot bind non-const lvalue reference of type 'AltIdent&' to an rvalue of type 'std::remove_ref

Всем доброго времени суток.
Помогите разобраться, что я делаю не так?
Есть несколько классов. Вот они:

class AltIdent
{
public:
    AltIdent();
    AltIdent(const AltIdent &);
    AltIdent(PartNumber partnumber, ManufacturerCode manufacturercode);
    ~AltIdent(){}

    PartNumber getPartNumberObject() const;
    void setPartNumberObject(const PartNumber &value);

    ManufacturerCode getManufacturerCodeObject() const;
    void setManufacturerCodeObject(const ManufacturerCode &value);

bool isEmpty();
    AltIdent *isNull();
    AltIdent operator= (AltIdent &altident);

private:
    PartNumber partNumberObject;
    ManufacturerCode manufacturerCodeObject;
};

#include "altident.h"

AltIdent::AltIdent()
{

}

AltIdent::AltIdent(const AltIdent &altident)
{
    partNumberObject = altident.getPartNumberObject();
    manufacturerCodeObject = altident.getManufacturerCodeObject();
}

AltIdent::AltIdent(PartNumber partnumnber, ManufacturerCode manufacturercode):
    partNumberObject(partnumnber), manufacturerCodeObject(manufacturercode)
{

}

PartNumber AltIdent::getPartNumberObject() const
{
    return partNumberObject;
}

void AltIdent::setPartNumberObject(const PartNumber &value)
{
    partNumberObject = value;
}

ManufacturerCode AltIdent::getManufacturerCodeObject() const
{
    return manufacturerCodeObject;
}

void AltIdent::setManufacturerCodeObject(const ManufacturerCode &value)
{
    manufacturerCodeObject = value;
}

bool AltIdent::isEmpty()
{
    if(isNull() != nullptr){
        if(!getPartNumberObject().isEmpty()){
            return false;
        }
        if(!getManufacturerCodeObject().isEmpty()){
            return false;
        }
    }
    return true;
}

AltIdent *AltIdent::isNull()
{
    AltIdent *altIdent = this;
    if(altIdent != nullptr){
        return this;
    }
    return nullptr;
}

AltIdent AltIdent::operator=(AltIdent &altident)
{
    return *new AltIdent(altident.getPartNumberObject(), altident.getManufacturerCodeObject());
}

class PartNumber
{
public:
    PartNumber();
    PartNumber(const PartNumber &);
    PartNumber(const QString &partNumberStr, const QMap<QString, QString> &attrMap);
    ~PartNumber(){}

    QString getPartNumberValue() const;
    void setPartNumberValue(const QString &value);

    QMap<QString, QString> getPartNumberAttrMap() const;
    void setPartNumberAttrMap(const QMap<QString, QString> &value);

    bool isEmpty();
    PartNumber *isNull();

private:
    QString partNumberValue;
    QMap<QString, QString> partNumberAttrMap;
};

#include "partnumber.h"

PartNumber::PartNumber()
{

}

PartNumber::PartNumber(const PartNumber &partnumber)
{
    partNumberValue = partnumber.getPartNumberValue();
    partNumberAttrMap = partnumber.getPartNumberAttrMap();
}

PartNumber::PartNumber(const QString &partNumberStr, const QMap<QString, QString> &attrMap) :
    partNumberValue(partNumberStr), partNumberAttrMap(attrMap)
{

}

QMap<QString, QString> PartNumber::getPartNumberAttrMap() const
{
    return partNumberAttrMap;
}

void PartNumber::setPartNumberAttrMap(const QMap<QString, QString> &value)
{
    partNumberAttrMap = value;
}

QString PartNumber::getPartNumberValue() const
{
    return partNumberValue;
}

void PartNumber::setPartNumberValue(const QString &value)
{
    partNumberValue = value;
}

bool PartNumber::isEmpty()
{
    if(isNull() != nullptr && !partNumberValue.isEmpty()){
        return false;
    }
    return true;
}

PartNumber *PartNumber::isNull()
{
    PartNumber *partNumber = this;
    if(partNumber != nullptr){
        return this;
    }
    return nullptr;
}
class ManufacturerCode
{
public:
    ManufacturerCode();
    ManufacturerCode(const ManufacturerCode &);
    ManufacturerCode(const QString &manufacturerCode, const QMap<QString, QString> &attrMap);
    ~ManufacturerCode(){}

    QMap<QString, QString> getManufacturerCodeAttrMap() const;
    void setManufacturerCodeAttrMap(const QMap<QString, QString> &value);

    QString getManufacturerCodeValue() const;
    void setManufacturerCodeValue(const QString &value);

    QDomElement manufacturerCodeToXml(QDomDocument &domdocument);
    void manufacturerCodeFromXml(QDomElement &domelement);

    bool isEmpty();
    ManufacturerCode *isNull();

private:
    QString manufacturerCodeValue;
    QMap<QString, QString> manufacturerCodeAttrMap;

};

#include "manufacturercode.h"

ManufacturerCode::ManufacturerCode()
{

}

ManufacturerCode::ManufacturerCode(const ManufacturerCode &manufacturercode)
{
    *this = manufacturercode;
}

ManufacturerCode::ManufacturerCode(const QString &manufacturerCode,const QMap<QString, QString> &attrMap) :
    manufacturerCodeValue(manufacturerCode), manufacturerCodeAttrMap(attrMap)
{

}

QMap<QString, QString> ManufacturerCode::getManufacturerCodeAttrMap() const
{
    return manufacturerCodeAttrMap;
}

void ManufacturerCode::setManufacturerCodeAttrMap(const QMap<QString, QString> &value)
{
    manufacturerCodeAttrMap = value;
}

QString ManufacturerCode::getManufacturerCodeValue() const
{
    return manufacturerCodeValue;
}

void ManufacturerCode::setManufacturerCodeValue(const QString &value)
{
    manufacturerCodeValue = value;
}

bool ManufacturerCode::isEmpty()
{
    if(isNull() != nullptr && !manufacturerCodeValue.isEmpty()){
        return false;
    }
    return true;
}

ManufacturerCode *ManufacturerCode::isNull()
{
    ManufacturerCode *manufacturerCode = this;
    if(manufacturerCode != nullptr){
        return this;
    }
    return nullptr;
}

В другом файле сосздаю вектор:

    AltIdent m_altIdentOrigin;
    AltIdent m_altIdentCurrent;
    QVector<AltIdent> m_altIdentList;

На кнопку QPushButton повесил обработчик, который должен по индексу присвоить переменной m_altIdentCurrent элемент массива

void AltIdentGroupWidget::previewItem(const int &index)
{
    m_altIdentOrigin = m_altIdentList.at(index);
}

Но при компиляции получаю следующие ошибки:
1. C:\DEVELOPMENT\Qt5.12.9\5.12.9\mingw73_64\include\QtCore\qvector.h:687: ошибка: cannot bind non-const lvalue reference of type 'AltIdent&' to an rvalue of type 'std::remove_reference ::type {aka AltIdent}'
d->end() = qMove(copy);
2. C:\DEVELOPMENT\Qt5.12.9\5.12.9\mingw73_64\include\QtCore\qvector.h:693: ошибка: binding reference of type 'AltIdent&' to 'const AltIdent' discards qualifiers
d->end() = t;
~~~~~~~~~~^~~

И я не могу разобраться, что я делаю не так?
Помогите разобраться, пожалуйста.

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Do you like it? Share on social networks!

1
Intruder
  • Dec. 23, 2020, 3:05 p.m.

Еще у меня вопрос. Правильно ли я написал конструктор копирования и перегрузил операцию присваивания?

    Comments

    Only authorized users can post comments.
    Please, Log in or Sign up
    AD

    C ++ - Test 004. Pointers, Arrays and Loops

    • Result:50points,
    • Rating points-4
    m

    C ++ - Test 004. Pointers, Arrays and Loops

    • Result:80points,
    • Rating points4
    m

    C ++ - Test 004. Pointers, Arrays and Loops

    • Result:20points,
    • Rating points-10
    Last comments
    i
    innorwallNov. 11, 2024, 10:12 p.m.
    Django - Tutorial 055. How to write auto populate field functionality Freckles because of several brand names retin a, atralin buy generic priligy
    i
    innorwallNov. 11, 2024, 6:23 p.m.
    QML - Tutorial 035. Using enumerations in QML without C ++ priligy cvs 24 Together with antibiotics such as amphotericin B 10, griseofulvin 11 and streptomycin 12, chloramphenicol 9 is in the World Health Organisation s List of Essential Medici…
    i
    innorwallNov. 11, 2024, 3:50 p.m.
    Qt/C++ - Lesson 052. Customization Qt Audio player in the style of AIMP It decreases stress, supports hormone balance, and regulates and increases blood flow to the reproductive organs buy priligy online safe Promising data were reported in a PDX model re…
    i
    innorwallNov. 11, 2024, 2:19 p.m.
    Heap sorting algorithm The role of raloxifene in preventing breast cancer priligy precio
    i
    innorwallNov. 11, 2024, 1:55 p.m.
    PyQt5 - Lesson 006. Work with QTableWidget buy priligy 60 mg 53 have been reported by Javanovic Santa et al
    Now discuss on the forum
    i
    innorwallNov. 11, 2024, 8:56 p.m.
    добавить qlineseries в функции buy priligy senior brother Chu He, whom he had known for many years
    i
    innorwallNov. 11, 2024, 10:55 a.m.
    Всё ещё разбираюсь с кешем. priligy walgreens levitra dulcolax carbs The third ring was found to be made up of ultra relativistic electrons, which are also present in both the outer and inner rings
    9
    9AnonimOct. 25, 2024, 9:10 a.m.
    Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…

    Follow us in social networks