? ? ? ?在使用QComboBox調用clear()方法來清除下拉選項,確無緣無故的崩潰了,調試到QComboBox調用clear()方法這一語句時崩潰的,很詭異。
? ? ? 經過資料查找和分析,得出錯誤處,在以前調用clear()方法時沒有問題,但加入了connect(qcombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnComboIndexChanged(int)));這句時,此時再調用clear()方法,就會崩潰。
解決辦法是在調用clear()方法時先調用disconnect(qcombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnComboIndexChanged(int)));
在調用完clear()方法后再次調用
connect(qcombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnComboIndexChanged(int)));