Results 1 to 4 of 4

Thread: index out of range

  1. #1
    Join Date
    Sep 2019
    Posts
    14
    Thanks
    7
    Qt products
    Qt5
    Platforms
    MacOS X

    Smile index out of range

    I try to send UDP massage but I got this massage

    error.PNG

    How can I fix this
    here is my UDP sender code
    Qt Code:
    1. QString datagrama = ui->lw_catalogList->currentItem()->text();
    2. qDebug() << datagrama;
    3. //mSocket->writeDatagram()
    4. ui->lw_entityList->currentItem();
    5. QStringList allNamesAsAList;
    6. int names = ui->lw_entityList->count();
    7. for(int i = 0; i < names; i++)
    8. {
    9. allNamesAsAList << ui->lw_entityList->item(i)->text().toLatin1();
    10. }
    11. qDebug() << allNamesAsAList;
    12. for(int j = 0; j <= allNamesAsAList.size(); j++){
    13. QByteArray entity;
    14. entity.append(allNamesAsAList.at(j));
    15. mSocket->writeDatagram(entity, QHostAddress::LocalHost,12345);
    16. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,592
    Thanks
    13
    Thanked 1,586 Times in 1,515 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: index out of range

    Fix line 12.

  3. #3
    Join Date
    Sep 2019
    Posts
    14
    Thanks
    7
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: index out of range

    What did I do wrong?

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,376
    Thanks
    246
    Thanked 687 Times in 677 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: index out of range

    What did I do wrong?
    If you are indexing into an array, and the first index is zero, what should the last index value be?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. qstringlist index out of range at declaration!
    By fatecasino in forum Newbie
    Replies: 4
    Last Post: 30th April 2015, 17:33
  2. Index out of range problem for a xml file
    By Niamita in forum Qt Programming
    Replies: 1
    Last Post: 3rd November 2011, 08:11
  3. Replies: 6
    Last Post: 8th April 2011, 22:15
  4. Index out of Range
    By santhoshv84 in forum Qt Programming
    Replies: 2
    Last Post: 19th August 2008, 16:33
  5. QList index out of range problem
    By MarkoSan in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2008, 09:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.