Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. Warum kommt bei Qlist diese Fehlermeldung?
QtWS25 Last Chance

Warum kommt bei Qlist diese Fehlermeldung?

Scheduled Pinned Locked Moved Unsolved German
8 Posts 2 Posters 664 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.
  • S Offline
    S Offline
    sowas
    wrote on 21 Oct 2022, 12:08 last edited by
    #1

    Was mache ich falsch:
    #include <QCoreApplication>
    #include <QList>
    #include <QString>
    #include <QDebug

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    QList<QString> street = {"Allee","allee","Damm","damm","Gasse","gasse","Gäßchen","gäßchen","Graben","graben","Platz","platz","Straße","straße","Str.","str.","Weg","weg"};
    for (int i=0; street.size();i++ ){
          qDebug() << street.at(i) ;
      }
    
    
    return a.exec();
    

    }
    nach der Auflistung kommt folgende Meldung:
    ASSERT failure in QList<T>::at: "index out of range", file /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h, line 571
    Betätigen Sie die <RETURN> Taste, um das Fenster zu schließen...

    Wieso kommt hier eine Fehlermeldung?
    Danke Bk

    C 1 Reply Last reply 21 Oct 2022, 12:10
    0
    • S sowas
      21 Oct 2022, 12:08

      Was mache ich falsch:
      #include <QCoreApplication>
      #include <QList>
      #include <QString>
      #include <QDebug

      int main(int argc, char *argv[])
      {
      QCoreApplication a(argc, argv);

      QList<QString> street = {"Allee","allee","Damm","damm","Gasse","gasse","Gäßchen","gäßchen","Graben","graben","Platz","platz","Straße","straße","Str.","str.","Weg","weg"};
      for (int i=0; street.size();i++ ){
            qDebug() << street.at(i) ;
        }
      
      
      return a.exec();
      

      }
      nach der Auflistung kommt folgende Meldung:
      ASSERT failure in QList<T>::at: "index out of range", file /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h, line 571
      Betätigen Sie die <RETURN> Taste, um das Fenster zu schließen...

      Wieso kommt hier eine Fehlermeldung?
      Danke Bk

      C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 21 Oct 2022, 12:10 last edited by
      #2

      @sowas said in Warum kommt bei Qlist diese Fehlermeldung?:

      Wieso kommt hier eine Fehlermeldung?

      Darum:

      for (int i=0; street.size();i++ ){

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • S Offline
        S Offline
        sowas
        wrote on 21 Oct 2022, 12:19 last edited by
        #3

        Wie kann ich dann feststellen ob ein Begriff in der Liste ist, wenn nach einem Durchlauf dass Programm abstürzt?

        C 1 Reply Last reply 21 Oct 2022, 12:24
        0
        • S sowas
          21 Oct 2022, 12:19

          Wie kann ich dann feststellen ob ein Begriff in der Liste ist, wenn nach einem Durchlauf dass Programm abstürzt?

          C Online
          C Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 21 Oct 2022, 12:24 last edited by
          #4

          @sowas said in Warum kommt bei Qlist diese Fehlermeldung?:

          Wie kann ich dann feststellen ob ein Begriff in der Liste ist, wenn nach einem Durchlauf dass Programm abstürzt?

          Indem du eine korrekt for-Schleife baust - deine Abbruchbedingung ist, wie ich Dir schon gezeigt habe, falsch.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • S Offline
            S Offline
            sowas
            wrote on 21 Oct 2022, 12:33 last edited by
            #5

            Ich habe keine Ahnung was daran falsch sein soll die einzelnen Werte aufzurufen bis zum Ende der Schleife.

            1 Reply Last reply
            0
            • C Online
              C Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 21 Oct 2022, 12:36 last edited by
              #6

              Dann bitte mal lesen wie eine for-Schleife (und vor allem die Abbruchbedingung) auszusehen hat: https://www.c-howto.de/tutorial/schleifen/for-schleife/

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sowas
                wrote on 21 Oct 2022, 12:38 last edited by
                #7

                manchmal ist man schwer von Begriff. Danke

                1 Reply Last reply
                1
                • C Online
                  C Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 21 Oct 2022, 12:41 last edited by
                  #8

                  c++:style:

                  QList<QString> street = {"Allee","allee","Damm","damm","Gasse","gasse","Gäßchen","gäßchen","Graben","graben","Platz","platz","Straße","straße","Str.","str.","Weg","weg"};
                  for (const auto &str: street){
                        qDebug() << str;
                    }
                  

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0

                  4/8

                  21 Oct 2022, 12:24

                  • Login

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