Advertisement
Guest User

Удаление записи из браузера

a guest
Dec 22nd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void NumismatistHandbook::deleteItemSlot()
  2. {
  3.     int currentIndex = ui->listWidget->currentRow();
  4.  
  5.     if (currentIndex != -1)
  6.     { //выбран существующий элемент
  7.         //удалить из массива
  8.         uint32_t currentId = ui->listWidget->currentItem()->data(Qt::UserRole).toUInt();
  9.         int currentIndex = ui->listWidget->currentRow();
  10.         model.remove(currentId);
  11.         delete ui->listWidget->takeItem(currentIndex);
  12.     }
  13.  
  14.     //выбор нового индекса
  15.     int newIndex = currentIndex;
  16.     if (currentIndex >= model.count())
  17.          newIndex -= 1;
  18.  
  19.     ui->listWidget->setCurrentRow(newIndex);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement