binding to reference of type discards qualifiers

  • I don't know why I have this kind of error. I don't use any of const value. append() gives the same error. Does it have anything to do with the fact that append() require const T &value? I'm pretty sure that something like that worked good for me in the past. What can be wrong here?

    full error msg:
    C:\Qt\Qt5.10.1\5.10.1\mingw53_32\include\QtCore\qlist.h:-1: In instantiation of 'void QList<T>::node_construct(QList<T>::Node*, const T&) [with T = DobotMove]':
    C:\Qt\Qt5.10.1\5.10.1\mingw53_32\include\QtCore\qlist.h:584: required from 'void QList<T>::append(const T&) [with T = DobotMove]'
    C:\Qt\Qt5.10.1\5.10.1\mingw53_32\include\QtCore\qlist.h:386: required from 'QList<T>& QList<T>::operator<<(const T&) [with T = DobotMove]'
    C:\DobotChess\dobot\dobot_queue.cpp:191: required from here
    C:\Qt\Qt5.10.1\5.10.1\mingw53_32\include\QtCore\qlist.h:441: błąd: binding 'const DobotMove' to reference of type 'DobotMove&' discards qualifiers
    else reinterpret_cast<T>(n) = t;
    C:\DobotChess\dobot\dobot_queue.cpp:1: In file included from dobot\dobot_queue.cpp:1:0:
    C:\DobotChess\dobot\dobot_queue.h:12: note: initializing argument 1 of 'DobotMove& DobotMove::operator=(DobotMove&)'
    struct DobotMove

    QList<DobotMove> _queuedCmdIDList;
    struct DobotMove
        uint64_t ID;
        DOBOT_MOVE_TYPE type;
        Point3D xyz;
        DobotMove() :ID(0), type(DM_NONE), xyz(0,0,0) {}
        DobotMove(uint64_t id, DOBOT_MOVE_TYPE MT, Point3D p): ID(id), type(MT), xyz(p) {}
    void DobotQueue::addArmMoveToQueue(DOBOT_MOVE_TYPE Type, Point3D point)
        _un64CoreQueuedCmdID += 1;
        DobotMove cmdToQueue(_un64CoreQueuedCmdID, Type, point);
        _queuedCmdIDList << cmdToQueue; //HERE

    Also it would be better to have list of pointers to structs, or just list of structs?

Log in to reply