[SOLVED]QStringList index problem



  • Hello!

    I would like to ask for help.

    If I write follow code (gep_pakli is a QStringList), then I get an error during running:
    @kartya = gep_pakli.at(i);@

    but if I write follow code then running without error:
    @kartya = gep_pakli.at(3);@

    Why not working if I use (int) variable?

    Error:
    ASSERT failure in QList<T>::take: "index out of range", file /Users/ivanicsmark/Qt5.2.1/5.2.1/clang_64/lib/QtCore.framework/Headers/qlist.h, line 488

    (I use OS X, but I would like use on Windows later.)

    Thank you!



  • Hi, it will work with an integer variable as well.
    Make sure, your variable has a content which is represented in your QList - you may want to test it with qDebug() << i;



  • [quote author="Clochydd" date="1397405737"]Hi, it will work with an integer variable as well.
    Make sure, your variable has a content which is represented in your QList - you may want to test it with qDebug() << i;[/quote]

    It's working. The for loop is running 0-5, but the data for QStringList have 0-4.

    Thank you for helping!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.