在我的項目中,我有一個listWidget。當用戶點擊列表中的一個項目時,它會加載:Qt當listWidget項被點擊兩次時崩潰
void BlockSelect::on_blockList_clicked(const QModelIndex &index)
{
QString blockListName;
QString temp_hex;
QString temp_hex2;
int temp_int;
QListWidgetItem *newitem = ui->blockList->currentItem();
blockListName = newitem->text();
temp_hex = blockListName.mid(0, blockListName.indexOf(" "));
if(temp_hex.indexOf(":") == -1)
{
temp_int = temp_hex.toInt();
ui->blockIdIn->setValue(temp_int);
ui->damageIdIn = 0;
}
else
{
temp_hex2 = temp_hex.mid(temp_hex.indexOf(":")+1, temp_hex.length()-(temp_hex.indexOf(":")+1));
temp_hex = temp_hex.mid(0, temp_hex.indexOf(":"));
temp_int = temp_hex.toInt();
ui->blockIdIn->setValue(temp_int);
temp_int = temp_hex2.toInt();
ui->damageIdIn->setValue(temp_int);
}
}
大部分情況是字符串操作。 (你不需要學習這個語法或任何東西)
我的問題是,當用戶快速點擊另一個列表項(在當前過程完成之前)程序崩潰。有什麼辦法可以快速點擊(多個進程一次)或者可能是一個替代解決方案?
感謝您的時間:)
這個問題是關於一個錯字。除提問者之外,問題和答案都不會對任何人有任何幫助。請參閱[這篇meta文章](http://meta.stackexchange.com/questions/167342/close-all-the-typo-questions)瞭解一些基本原理。 –