Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;-Qt奇怪的QList::at()错误_C++_Qt - Fatal编程技术网

C++ C++;-Qt奇怪的QList::at()错误

C++ C++;-Qt奇怪的QList::at()错误,c++,qt,C++,Qt,这只是最近的一个错误。昨天天气很好,没有对节目做任何改动!每次我保存愿望列表并重新启动程序时,它都会将所有愿望列表读取到qlist中。因此,一旦列表中至少有一项,它就不会抛出此错误 有什么想法吗?怎么了 更新: ASSERT failure in QList<T>::at: "index out of range", file ../../../Qt5.5.1/5.5/gcc_64/include/QtCore/qlist.h, line 510 The program has un

这只是最近的一个错误。昨天天气很好,没有对节目做任何改动!每次我保存愿望列表并重新启动程序时,它都会将所有愿望列表读取到qlist中。因此,一旦列表中至少有一项,它就不会抛出此错误

有什么想法吗?怎么了

更新:

ASSERT failure in QList<T>::at: "index out of range", file ../../../Qt5.5.1/5.5/gcc_64/include/QtCore/qlist.h, line 510
The program has unexpectedly finished.
0\u GI\u raise/usr/lib/debug/lib/x86\u 64-linux-gnu/libc-2.19.so 56 0x7ffff5d5acc9
1\uuu GI\u abort/usr/lib/debug/lib/x86\u 64-linux-gnu/libc-2.19.so 89 0x7ffff5d5e0d8
2 QMessageLogger::致命(常量字符*,…)常量0x7ffff669513e
3 qt_assert_x(常量字符*,常量字符*,常量字符*,int)0x7ffff6690701
4 QList::at QList.h 510 0x40c725
5 MainWindow::updateListView MainWindow.cpp 204 0x408539
6 MainWindow::onWishlistChanged MainWindow.cpp 99 0x407c2e
7主窗口::qt_static_metacall moc_MainWindow.cpp 102 0x413520
8 QMetaObject::激活(QObject*,int,int,void**)0x7ffff68c335e
9 QComboBox::currentIndexChanged(int)0x7ffff77be121
10  ??          0x7ffff77c0451
11  ??          0x7ffff77c26dd
12 QComboBox::setCurrentIndex(int)0x7ffff77c294f
13  ??          0x7ffff77c79d9
14 QMetaObject::激活(QObject*,int,int,void**)0x7ffff68c335e
15 QAbstractItemModel::rowsInserted(QModelIndex const&,int,int,QAbstractItemModel::QPrivateSignal)0x7ffff693fd84
16 QBStractItemModel::endInsertRows()0x7ffff683fea2
17  ??          0x7ffff71cd5bb
18 QComboBox::插入项(int、QIcon常量&、QString常量&、QVariant常量&)0x7ffff77c3f18
19 QComboBox::insertItem QComboBox.h 268 0x4092a8
...               

看起来崩溃更可能发生在:

0   __GI_raise  /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.19.so    56  0x7ffff5d5acc9  
1   __GI_abort  /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.19.so    89  0x7ffff5d5e0d8  
2   QMessageLogger::fatal(const char *, ...) const          0x7ffff669513e  
3   qt_assert_x(const char *, const char *, const char *, int)          0x7ffff6690701  
4   QList<WishList>::at qlist.h 510 0x40c725    
5   MainWindow::updateListView  mainwindow.cpp  204 0x408539    
6   MainWindow::onWishlistChanged   mainwindow.cpp  99  0x407c2e    
7   MainWindow::qt_static_metacall  moc_mainwindow.cpp  102 0x413520    
8   QMetaObject::activate(QObject *, int, int, void * *)            0x7ffff68c335e  
9   QComboBox::currentIndexChanged(int)         0x7ffff77be121  
10  ??          0x7ffff77c0451  
11  ??          0x7ffff77c26dd  
12  QComboBox::setCurrentIndex(int)         0x7ffff77c294f  
13  ??          0x7ffff77c79d9  
14  QMetaObject::activate(QObject *, int, int, void * *)            0x7ffff68c335e  
15  QAbstractItemModel::rowsInserted(QModelIndex const&, int, int, QAbstractItemModel::QPrivateSignal)          0x7ffff693fd84  
16  QAbstractItemModel::endInsertRows()         0x7ffff683fea2  
17  ??          0x7ffff71cd5bb  
18  QComboBox::insertItem(int, QIcon const&, QString const&, QVariant const&)           0x7ffff77c3f18  
19  QComboBox::insertItem   qcombobox.h 268 0x4092a8    
... <More>              
由于您的调用堆栈位于一些与模型相关的更新代码中,您可能希望首先添加到列表中:

            wishlistBox->addItem( text );

因为我不希望简单地修改QList就能得到这样一个调用堆栈。

亲爱的Downvoter,请告诉我你为什么否决并建议结束这个问题。
WishList
“确切类型是什么?调用堆栈失败时会是什么样子?@LogicStuff这是一个自定义类型,但在这里发布太长了。这也不是问题所在,因为一旦列表中至少有一个项目,它就会工作。如果没有
wishLists
code,人们怎么可能知道错误是什么?
wishLists
中有错误,但您不会显示代码。请发一封电子邮件。
            wishlistBox->addItem( text );
            wishLists.push_back( wishlist );
            wishlistBox->addItem( text );