QList<int> function() 函数可以返回NULL,或者什么都不返回么?

 QList<int> UI_Proc_AVPOSE_StoreSerial_Desktop::accordingGroupGetIndexList(int mGroupId)
{
    for(int i = 0; i < mPlayerList.size(); i++)
    {
        if(mPlayerList.at(i)->mGroupID == mGroupId)
            return mPlayerList.at(i)->mIndexID;
    }
}

以上代码会让程序 崩溃。

Debug模式F10往下面走会执行一段


template <typename T>
Q_OUTOFLINE_TEMPLATE void QList<T>::dealloc(QListData::Data *data)
{
    node_destruct(reinterpret_cast<Node *>(data->array + data->begin),
                  reinterpret_cast<Node *>(data->array + data->end));
    QListData::dispose(data);
}

这样就不会崩溃掉

但是debug 模式下,不调试。release模式下,都会崩溃掉。。。蛋疼了一天了,麻烦Qt大神解释下/。。。

返回值类型为QList所以必须要有return值,而你那个如果if为false,则没有返回值会报错,所以你可以在头文件声明一个Qlist变量,然后在这个函数中赋值,改变函数的返回类型为void;返回值用赋值代替;

QList UI_Proc_AVPOSE_StoreSerial_Desktop::accordingGroupGetIndexList(int mGroupId)
我想知道上面函数的返回值,为什么会是QList,有这样的用法吗????

你好,第一次提问,编辑器不太会用,现在正常了

mPlayerList.at(i)->mIndexID 这个的类型是QList吗

首先声明:有return的都是返回的对的值,只是在if判断后,有可能为空值,function接受不返么???