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. Index out of range error

Index out of range error

Scheduled Pinned Locked Moved Unsolved General and Desktop
qstringlistqstringconcatanationruntimeerror
5 Posts 3 Posters 1.8k 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.
  • L Offline
    L Offline
    Lasith
    wrote on 20 Oct 2017, 09:13 last edited by
    #1

    In my qt c++ application when I insert a text value concatenated with a comma opeartor I get a runtime error stating "Index out of range"! But with out comma if I only insert the line edit value to the QStringList there is no runtime error!

    Following code works

    QStringList myList;
    myList<<ui->lineedit1->text();

    but following gives a runtime error!

    QStringList myList;
    myList<<ui->lineedit1->text()+",";

    How can I correct this issue?

    J 1 Reply Last reply 20 Oct 2017, 09:19
    0
    • L Lasith
      20 Oct 2017, 09:13

      In my qt c++ application when I insert a text value concatenated with a comma opeartor I get a runtime error stating "Index out of range"! But with out comma if I only insert the line edit value to the QStringList there is no runtime error!

      Following code works

      QStringList myList;
      myList<<ui->lineedit1->text();

      but following gives a runtime error!

      QStringList myList;
      myList<<ui->lineedit1->text()+",";

      How can I correct this issue?

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 20 Oct 2017, 09:19 last edited by
      #2

      @Lasith by using the intended QStringList functions instead if an abstract and overloaded operator

      QStringList myList;
      myList.append(ui->lineedit1->text()+",");


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      L 1 Reply Last reply 20 Oct 2017, 09:24
      0
      • J J.Hilk
        20 Oct 2017, 09:19

        @Lasith by using the intended QStringList functions instead if an abstract and overloaded operator

        QStringList myList;
        myList.append(ui->lineedit1->text()+",");

        L Offline
        L Offline
        Lasith
        wrote on 20 Oct 2017, 09:24 last edited by
        #3

        @J.Hilk Thanx but I still get the run time error :(

        J 1 Reply Last reply 20 Oct 2017, 09:32
        0
        • L Lasith
          20 Oct 2017, 09:24

          @J.Hilk Thanx but I still get the run time error :(

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 20 Oct 2017, 09:32 last edited by
          #4

          @Lasith are you sure it actually crashes at that line?


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 20 Oct 2017, 13:29 last edited by
            #5

            Hi
            Normally its the

            that can give "index out of range error"

            not when inserting ?

            1 Reply Last reply
            0

            1/5

            20 Oct 2017, 09:13

            • Login

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