Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    QList erase problem

    General and Desktop
    2
    4
    1391
    Loading More Posts
    • 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.
    • 8
      8majkel8 last edited by

      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
      @

      1 Reply Last reply Reply Quote 0
      • M
        mcosta last edited by

        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

        Once your problem is solved don't forget to:

        • Mark the thread as SOLVED using the Topic Tool menu
        • Vote up the answer(s) that helped you to solve the issue

        You can embed images using (http://imgur.com/) or (http://postimage.org/)

        1 Reply Last reply Reply Quote 0
        • 8
          8majkel8 last edited by

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

          1 Reply Last reply Reply Quote 0
          • M
            mcosta last edited by

            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

            Once your problem is solved don't forget to:

            • Mark the thread as SOLVED using the Topic Tool menu
            • Vote up the answer(s) that helped you to solve the issue

            You can embed images using (http://imgur.com/) or (http://postimage.org/)

            1 Reply Last reply Reply Quote 0
            • First post
              Last post