Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. ASSERT failure in QList<T>::at: "index out of range"
Forum Update on Monday, May 27th 2025

ASSERT failure in QList<T>::at: "index out of range"

Scheduled Pinned Locked Moved Solved General and Desktop
qlistqstringlistc++qurlqt 5.7
24 Posts 4 Posters 25.4k Views
  • 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.
  • Q Qjay
    26 Jul 2016, 12:13

    @Paul @SGaist , i don't know why but i am never able to initialize QUrl url :( ;

    AND I BELIEVE THAT"S WHAT CAUSING THE PROBLEM

    i have tried different approaches too . Like in my code i was using QStringList i even tried Qvector<QString> down_links and end result was same

    NOT ABLE TO set QUrl

    in console screen
    QUrl("")
    ""
    

    What shoudl i do ?

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 26 Jul 2016, 12:33 last edited by
    #12

    @Qjay Can you show the code where you initialize QUrl? From your description we can only guess what could be the problem. Are you sure you don't pass an empty string to QUrl?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      Qjay
      wrote on 26 Jul 2016, 16:10 last edited by
      #13

      @jsulm , i have given the whole code

      https://ghostbin.com/paste/v4t47

      by the way this is where i set QUrl

      line no 371

       QUrl url = v.toStringList().at(current);
              qDebug() << "why break" << url;
      
      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 26 Jul 2016, 21:38 last edited by
        #14

        Again, did you check that the value of current is lower than the size of the string list ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          Qjay
          wrote on 27 Jul 2016, 03:37 last edited by
          #15

          I have initialized current =0; in global scope .

          J 1 Reply Last reply 27 Jul 2016, 04:15
          0
          • Q Qjay
            27 Jul 2016, 03:37

            I have initialized current =0; in global scope .

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 27 Jul 2016, 04:15 last edited by
            #16

            @Qjay But is it changed somewhere?
            Why not just check like this?

            qDebug() << v.toStringList().size() << current;
            qDebug() << v.toStringList().at(current);
            QUrl url = v.toStringList().at(current);
            

            In such a situation this is actually the first thing to do...

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • Q Offline
              Q Offline
              Qjay
              wrote on 27 Jul 2016, 08:18 last edited by
              #17

              hey @jsulm

              i tried what you suggested

              qDebug() << v.toStringList().size() << current;
              qDebug() << v.toStringList().at(current);
              QUrl url = v.toStringList().at(current);
              

              i did this

              qDebug() << "stringlist size and current" << v.toStringList().size() << current;
                      qDebug() << "current url in stringlist" << v.toStringList().at(current);
                      QUrl url = v.toStringList().at(current);
                      qDebug() << "why break" << url;
              

              output

              stringlist size and current 33 0
              current url in stringlist   "(http://restbase.wikitolearn.org/en.wikitolearn.org/v1/media/math/render/svg/3cd95482da53d42c5f7f249454f7ee1e85cacc0c)"
              why break QUrl("")
              ""
              

              and then error

              ASSERT failure in QList<T>::at: "index out of range", file ../../Qt5.7.0/5.7/gcc_64/include/QtCore/qlist.h, line 537
              The program has unexpectedly finished.
              
              J 1 Reply Last reply 27 Jul 2016, 09:17
              0
              • Q Qjay
                27 Jul 2016, 08:18

                hey @jsulm

                i tried what you suggested

                qDebug() << v.toStringList().size() << current;
                qDebug() << v.toStringList().at(current);
                QUrl url = v.toStringList().at(current);
                

                i did this

                qDebug() << "stringlist size and current" << v.toStringList().size() << current;
                        qDebug() << "current url in stringlist" << v.toStringList().at(current);
                        QUrl url = v.toStringList().at(current);
                        qDebug() << "why break" << url;
                

                output

                stringlist size and current 33 0
                current url in stringlist   "(http://restbase.wikitolearn.org/en.wikitolearn.org/v1/media/math/render/svg/3cd95482da53d42c5f7f249454f7ee1e85cacc0c)"
                why break QUrl("")
                ""
                

                and then error

                ASSERT failure in QList<T>::at: "index out of range", file ../../Qt5.7.0/5.7/gcc_64/include/QtCore/qlist.h, line 537
                The program has unexpectedly finished.
                
                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 27 Jul 2016, 09:17 last edited by
                #18

                @Qjay Why is the URL in parentheses?

                (http://restbase.wikitolearn.org/en.wikitolearn.org/v1/media/math/render/svg/3cd95482da53d42c5f7f249454f7ee1e85cacc0c)
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 27 Jul 2016, 10:39 last edited by
                  #19

                  Looks like you are doing a lot of parsing, replacement etc.

                  The first thing I'd do, is to just ensure that you really have URLs in your list. And get rid of that QVariant parameter. It really doesn't make any sense in your use case.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    Qjay
                    wrote on 27 Jul 2016, 15:48 last edited by Qjay
                    #20

                    Hello , thanks for the suggetions .

                    1. yes there were useless ( ) in url . i have removed them . Now i am able to assign url to Qurl :D great!!

                    2. i removed the Qvariant thing too

                    now the code is

                    .cpp : https://ghostbin.com/paste/vv2w7

                    header file : https://ghostbin.com/paste/8z4y3

                    but the assert error still exist :/

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 27 Jul 2016, 21:21 last edited by
                      #21

                      Still at the same place ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • Q Offline
                        Q Offline
                        Qjay
                        wrote on 29 Jul 2016, 12:09 last edited by
                        #22

                        Hey @SGaist , @jsulm , thank you it's solved now

                        To be honest i don't know why it worked :/

                        but below is the code

                        https://ghostbin.com/paste/528m6

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 29 Jul 2016, 21:40 last edited by
                          #23

                          From the looks of it, you're currently lucky.

                          I'd recommend considering refactoring and cleaning up this code. Maybe a full rewrite would even be better.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • Q Offline
                            Q Offline
                            Qjay
                            wrote on 30 Jul 2016, 08:02 last edited by
                            #24

                            I too was also thinking of full rewrite but i don't have much time for that right now :/ .

                            1 Reply Last reply
                            0

                            21/24

                            27 Jul 2016, 21:21

                            • Login

                            • Login or register to search.
                            21 out of 24
                            • First post
                              21/24
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved