1

我有 3 个列表,一个idList,一个filmList和一个songList。从 中删除或添加项目时,QListWidget也应在其中两个列表中删除它(在idList+filmList或中songList)。然而,这不是问题。问题是当我从列表中删除 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);
        }
    }
}
4

0 回答 0