Qt删除当前的ListWidgetItem导致崩溃

时间:2013-11-08 15:52:59

标签: c++ qt

我有3个列表,idListfilmListsongList。从QListWidget删除或添加项目时,也应删除其中两个列表(idList + filmListsongList)。但是,这不是问题所在。问题是,当我从列表中删除恰好8个项目时,程序崩溃了。

怎么了?

connect( removeButton, SIGNAL( clicked() ), this, SLOT( remove() ) );

//My remove function
void MainWindow::remove()
{
    if( list->currentRow() != -1 ){
        const unsigned int row = list->currentRow();
        if( dm->remove( categoryBox->currentText(), idList.at( row ) ) )
        {
            idList.removeAt( row );

            //Remove from specific list
            if( currentCategory() == cFilm )
                filmList.removeAt( row );
            else if( currentCategory() == cSong )
                songList.removeAt( row );
            else if( currentCategory() == cApp )
                ;

            delete list->takeItem(row);
        }
    }
}

0 个答案:

没有答案