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

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

By : Luis Alberto Amara
Date : November 16 2020, 06:23 AM
I wish this helpful for you I think I have managed to reproduce your issue.
in on_comboBox_Tabel_Select_currentIndexChanged there is a line:
code :
QStringList invoice  = (QStringList() << "Invoice Number"
                                      << "Date Time"
                                      << "Total Purchased"
                                      << "Company Name" 
                                      << "Company Owner");
QStringList invoice  = (QStringList() << "Invoice_Number"
                                      << "Date_Time"
                                      << "Total_Purchased");

Share : facebook icon twitter icon
ASSERT failure in QList<T>::at: "index out of range" in Qt 5

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

By : Gestellen
Date : March 29 2020, 07:55 AM
around this issue I want to generate *.png files from my directory randomly in qt using qrand() function. to do that I have created a QStringList object so that I can store all files I have in my directory.thinking that I have some list of files in my QStringList object when I run my application it crush. , The answer is in the error:
code :
applicationPath = "C:\\Users\\Tekme\Documents\\QtProject\\4Toddler";
applicationPath = "C:\\Users\\Tekme\\Documents\\QtProject\\4Toddler";
ASSERT failure in QList<T>::operator[]: "index out of range"

ASSERT failure in QList<T>::operator[]: "index out of range"

By : wakarana1
Date : March 29 2020, 07:55 AM
wish helps you The decoder will perform better if you make the parsing more explicit in the formalism of a parser. A two-state machine will do the job. Below is a full test case:
code :
// https://github.com/KubaO/stackoverflown/tree/master/questions/packet-read-43228728
#include <QtTest>
#include <private/qringbuffer_p.h>

// See http://stackoverflow.com/a/32317276/1329652
/// A simple point-to-point intra-process pipe. The other endpoint can live in any
/// thread.
class AppPipe : public QIODevice {

class Decoder : public QObject {
   QPointer<QIODevice> m_device;
   QByteArray m_data;
   char m_first;
   bool m_isFirst = true;
   static constexpr char fromHex(char c) {
            (c >= '0' && c <= '9') ? (c - '0') :
            (c >= 'A' && c <= 'F') ? (c - 'A' + 10) :
            (c >= 'a' && c <= 'f') ? (c - 'a' + 10) :
   void decode(const QByteArray & src) {
      for (auto c : src) {
         auto val = fromHex(c);
         if (val < 0) continue;
         if (m_isFirst)
             m_first = val << 4;
             m_data.append(m_first | val);
         m_isFirst = !m_isFirst;
   void onReadyRead() {
      // The data has the format "XX XX XX" where X are hex digits.
      // Spaces and invalid digits are skipped
      if (m_data.size() >= 4) {
         auto length = 4 + m_data[3];
         if (m_data.size() >= length) {
            emit hasMessage(m_data.left(length));
            m_data.remove(0, length);
   Decoder(QIODevice * dev, QObject * parent = {}) : QObject{parent}, m_device{dev} {
      connect(dev, &QIODevice::readyRead, this, &Decoder::onReadyRead);
   Q_SIGNAL void hasMessage(const QByteArray &);

class DecoderTest : public QObject {
   AppPipe src{nullptr, QIODevice::ReadWrite};
   AppPipe dst{&src, QIODevice::ReadWrite};
   Q_SLOT void initTestCase() {
   Q_SLOT void test1() {
      Decoder dec(&dst, this);
      QSignalSpy spy(&dec, &Decoder::hasMessage);

      src.write("0"); // send a partial header
      QCOMPARE(spy.size(), 0);
      src.write("0 00 00 03 "); // send rest of the header
      QCOMPARE(spy.size(), 0);
      src.write("0A 0B "); // send partial data
      QCOMPARE(spy.size(), 0);
      src.write("0C "); // send rest of data
      QCOMPARE(spy.size(), 1);

      QCOMPARE(dst.bytesAvailable(), 0); // ensure all data has been read

      const QByteArray packet{"\x00\x00\x00\x03\x0A\x0B\x0C", 4+3};
      QCOMPARE(spy.first().size(), 1);
      QCOMPARE(spy.first().first(), {packet});
   Q_SLOT void test2() {
      Decoder dec(&dst, this);
      QSignalSpy spy(&dec, &Decoder::hasMessage);

      src.write("BABE0004 C001 DA7E\n0FAB33"); // send a packet and part of another
      QCOMPARE(spy.size(), 1);
      src.write("01 AB\n");
      QCOMPARE(spy.size(), 2);

      QCOMPARE(spy.at(0).size(), 1);
      QCOMPARE(spy.at(1).size(), 1);
      const QByteArray packet1{"\xBA\xBE\x00\x04\xC0\x01\xDA\x7E", 4+4};
      const QByteArray packet2{"\x0F\xAB\x33\x01\xAB", 4+1};
      QCOMPARE(spy.at(0).first(), {packet1});
      QCOMPARE(spy.at(1).first(), {packet2});

#include "main.moc"
ASSERT failure in QList<T>::operator[]: "index out of range" file /usr/include/arm-linux-gnueabihf/qt5/Q

ASSERT failure in QList<T>::operator[]: "index out of range" file /usr/include/arm-linux-gnueabihf/qt5/Q

By : Vasilis Stasinopoulo
Date : March 29 2020, 07:55 AM
I wish this helpful for you I have recently been working on a project. When I attempt to run the project I get this error: , This is working fine.
code :
startvaluexy = EchoClient::straightxy;
qDebug() << "start xy value Received from server :" << startvaluexy;
QStringList xy = startvaluexy.split("|");
int xySize = xy.size();
qDebug() << "start xy size :" << xySize;

if(xySize < 4){
    return false;

bool ok;
int x = xy[2].toInt(&ok);
    return false;

int y = xy[3].toInt(&ok);
    return false;

return true;
QAbstractListModel.match() causes ASSERT failure in QList<T>::operator[]: "index out of range"

QAbstractListModel.match() causes ASSERT failure in QList<T>::operator[]: "index out of range"

By : user2656139
Date : March 29 2020, 07:55 AM
wish help you to fix your issue As indicated by the docs match, you can return an empty list so before accessing you must verify that you have at least the necessary number of elements:
code :
QModelIndexList indexes = m_DataSourceModel.match(m_DataSourceModel.index(0, 0),
    QModelIndex childIndex = indexes.first();
    // or QModelIndex childIndex = indexes[0];
qt ASSERT failure in QList<T>::at: "index out of range"

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

By : Vincent Keunen
Date : March 29 2020, 07:55 AM
will help you I ran into a similar issue because I did a connect on itemChanged before populating the widget and then while populating my slot code was called. After I put in a guard that prevented signal handling during widget population, I found I could populate the widget fine and I could also handle the signal fine after. Hope this helps.
Related Posts Related Posts :
  • How to wrap std::chrono in a c++ iterator type
  • Check if a socket is connected in mac os x
  • Grabbing the mouse cursor in GLFW
  • Calling Windows shell menu (same as right-click in Explorer) for multiple files programmatically
  • Pop up dialog to save file in seperate thread
  • Why would you use the keyword const if you already know variable should be constant?
  • Detecting Small Sound Effects In C++
  • How to avoid the copy when I return
  • Getting error code C2228: left of '._Ptr' must have class/struct/union
  • In win32 C++ programming how can I duplicate a window style?
  • Should the order of import statements matter when importing a .so?
  • Design decision regarding std::array fill
  • Access array of C++ structs from Fortran?
  • Determining when functions allocate memory in C++
  • C++ using std::set remove duplicate item for a struct fail.
  • Code to find out the number of triplets which lead to a sum less than or equal to threshold is giving a wrong output
  • Converting glm::lookat matrix to quaternion and back
  • Searching multi-dimensional vectors
  • Send and receive via SOCKS5 c++
  • GDI+: unhandled exception when drawing bitmap
  • Editing other processes memory
  • Object deleted when its member function is being executed?
  • Infinite Loop while inputting the different data type values in STACK
  • const members and operator=
  • Threaded Video Player sync
  • Does infinite of floating point number satisfy these equation?
  • map sorting in c++ by the frequencies
  • The Preprocessor program linked in g++ similar to the cpp program in gcc
  • How is the union used in this OpenCV library?
  • C++ memory leak in recursion
  • C++ Error: C4430 and C2143 Error at an impossible place
  • How can I track object lifetime in C++11 lambda?
  • #include statement mapping in Biicode (biicode.conf)
  • std::equal gives "Term doesnt evaluate to a function taking 2 arguments"
  • C++ template argument as reference lvalue
  • Legal to forward declare C standard library entities but not C++ standard library entities?
  • Conversion of wchar_t* to string
  • VirtualTreeView - Embarcadero C++ Builder XE7 - 64 bits
  • I don't understand C++ pointer arithmetic
  • Invalid addition of constness? Error: Cannot use char** to initialize const char**
  • Initilize constructor of class from another class
  • what happens when a class object is used as an index for an array?
  • Read and straighten multiple images from vector string, get error: "vector subscript out of range" [c++]
  • Meaning of a few lines in C++
  • Map, pair-vector or two vectors...?
  • Redefinition error in ostream overload in template and inherited classes
  • CUDA 6.5: error MSB3191 Unable to create directory and LNK2001 Unresolved External symbol
  • Is it possible to overlap batched FFTs with CUDA's cuFFT library and cufftPlanMany?
  • How to delete function from DLL binary
  • How do I loop over a boost MPL list of non-default constructed classes?
  • Download page using IE engine + use POST
  • How to insert an element into ublas matrix with dynamic size
  • Using typedefs appropriately to avoid "typedef contamination"
  • C++ Simple Converting from Binary to Decimal
  • error deleting item from list after passing through function
  • C++: RVO, NRVO and returning local objects
  • performance map c++ find (g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3))
  • How to change the fundamental underlying container type for the adaptor containers?
  • Crash when SAFE_RELEASE is called on IMMDeviceEnumerator
  • Visual Studio C++, how to change the text color for "nullptr"
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org