使用定時器我重複調用插槽checkBookings()
。 我能夠編譯和運行該程序,但在執行上述FOR循環時會崩潰。QList索引超出範圍
Error:"ASSERT failure in QList::at: "index out of range", file ../../../../Qt/2010.05/qt/include/QtCore/../../src/corelib/tools/qlist.h, line 455 Invalid parameter passed to C runtime function. Invalid parameter passed to C runtime function."
我的代碼是:
timer = new QTimer();
connect(timer,SIGNAL(timeout()),this,SLOT(checkBookings()));
timer->start(500000);
void Canvas::checkBookings()
{
QString dateStr;
for(int i= 0;i<=qlist.count();i++)
{
dateStr = qList.at(i).at(6);
}
}
除非您顯示變量qlist是什麼以及如何添加或刪除元素,否則這不會被回答。 – cgmb