Important: Please read the Qt Code of Conduct -

QList erase problem

  • Just an example.

    QVariantList list; //initialy empty
    QVariantList iterator curr = list.begin(); //could be list.end();

    list.erase(curr+1, QVariantList::end());
    //results in actually adding undefined element

  • Hi,

    what's the problem??
    You're doing a WRONG usage of QList API: before to use curr you MUST ensure that it is a valid iterator

  • yes i know ... but i think qlist should perform some simple checks (applications would be more stable that way).

  • Sincerely I don't agree with you.
    Applications would be more stable if developers would write good code; C++ isn't Java or VB, developers must write safe code and they'll have fast applications

Log in to reply